Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHARED-860] suppress deprecations and clean up test methods #46

Merged
merged 7 commits into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
/**
* @author Kristian Rosenvold
*/
@SuppressWarnings( "deprecation" )
public class MatchPatternTest
{
@Test
public void matchPath()
throws Exception
{
MatchPattern mp = MatchPattern.fromString( "ABC*" );
assertTrue( mp.matchPath( "ABCD", true ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
/**
* @author Kristian Rosenvold
*/
@SuppressWarnings( "deprecation" )
public class MatchPatternsTest
{
@Test
public void matches()
throws Exception
{
MatchPatterns from = MatchPatterns.from( "ABC**", "CDE**" );
assertTrue( from.matches( "ABCDE", true ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

/**
* Test the {@link SelectorUtils} class.
*
*/
@SuppressWarnings( "deprecation" )
public class SelectorUtilsTest
{

Expand Down Expand Up @@ -67,7 +67,6 @@ public void testAntPatternStrings()
assertAntDoesNotMatch( "/aaa/", "\\aaa\\bbb" );
}


private void assertAntDoesNotMatch( String pattern, String target )
{
assertEquals( false, SelectorUtils.matchPatternStart( wrapWithAntHandler( pattern ), target ) );
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,26 @@
* under the License.
*/

import org.apache.maven.shared.utils.io.FileUtils;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;

import org.apache.commons.io.FileUtils;

import java.io.*;
import org.junit.rules.TemporaryFolder;

/**
* A few utility methods for file based tests
* A few utility methods for file based tests.
*/
public final class FileTestHelper
{

private FileTestHelper()
{
// utility function doesn't need a public ct
// utility function doesn't need a public constructor
}

public static void generateTestData( OutputStream out, long size )
Expand All @@ -54,14 +60,12 @@ public static void generateTestFile( File testfile, int size )
testfile.delete();
}

OutputStream os = new FileOutputStream( testfile );
generateTestData( os, size );
os.flush();
os.close();
try ( OutputStream os = new FileOutputStream( testfile ) ) {
generateTestData( os, size );
os.flush();
}
}



public static void createLineBasedFile( File file, String[] data )
throws IOException
{
Expand All @@ -70,11 +74,12 @@ public static void createLineBasedFile( File file, String[] data )
throw new IOException( "Cannot create file " + file + " as the parent directory does not exist" );
}

try ( PrintWriter out = new PrintWriter( new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) ) )
try ( Writer out = new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) )
{
for ( String aData : data )
{
out.println( aData );
out.write( aData );
out.write( System.getProperty( "line.separator" ) );
michael-o marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand All @@ -92,7 +97,7 @@ public static File newFile( TemporaryFolder folder, String filename )

if ( destination.exists() )
{
FileUtils.forceDelete( destination );
FileUtils.deleteQuietly( destination );
}
return destination;
}
Expand Down