From: Martin Stockhammer Date: Sat, 2 Sep 2017 17:17:01 +0000 (+0200) Subject: And another one for moving to java.nio X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=90250dc30481c976628d6a44bfe37c6b98e2d254;p=archiva.git And another one for moving to java.nio --- diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java index f8aea6e7a..a9aa171a1 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java @@ -51,8 +51,10 @@ import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; -import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -95,6 +97,8 @@ public class DefaultArchivaConfiguration { private Logger log = LoggerFactory.getLogger( DefaultArchivaConfiguration.class ); + private static String FILE_ENCODING = "UTF-8"; + /** * Plexus registry to read the configuration from. */ @@ -684,21 +688,21 @@ public class DefaultArchivaConfiguration */ private boolean writeFile( String filetype, String path, String contents ) { - File file = new File( path ); + Path file = Paths.get( path ); try { // Check parent directory (if it is declared) - if ( file.getParentFile() != null ) + if ( file.getParent() != null ) { // Check that directory exists - if ( !file.getParentFile().isDirectory() ) + if ( !Files.isDirectory( file.getParent() ) ) { // Directory to file must exist for file to be created return false; } } - FileUtils.writeStringToFile( file, contents, "UTF-8" ); + FileUtils.writeStringToFile( file.toFile(), contents, FILE_ENCODING); return true; } catch ( IOException e ) @@ -950,9 +954,9 @@ public class DefaultArchivaConfiguration for ( ManagedRepositoryConfiguration repo : (List) config.getManagedRepositories() ) { String repoPath = repo.getLocation(); - File repoLocation = new File( repoPath ); + Path repoLocation = Paths.get( repoPath ); - if ( repoLocation.exists() && repoLocation.isDirectory() && !repoPath.endsWith( + if ( Files.exists(repoLocation) && Files.isDirectory(repoLocation) && !repoPath.endsWith( "data/repositories/" + repo.getId() ) ) { repo.setLocation( repoPath + "/data/repositories/" + repo.getId() ); diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java index 2a2b6da65..7811bdfc6 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java @@ -19,8 +19,10 @@ package org.apache.archiva.configuration; * under the License. */ -import java.io.File; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.List; import javax.inject.Inject; import org.apache.archiva.common.utils.FileUtil; @@ -41,15 +43,17 @@ import org.springframework.test.context.ContextConfiguration; public class ArchivaConfigurationMRM789Test { + private static String FILE_ENCODING = "UTF-8"; + @Inject protected ApplicationContext applicationContext; @Inject FileTypes filetypes; - public static File getTestFile( String path ) + public static Path getTestFile( String path ) { - return new File( FileUtil.getBasedir(), path ); + return Paths.get( FileUtil.getBasedir(), path ); } protected T lookup( Class clazz, String hint ) @@ -62,22 +66,22 @@ public class ArchivaConfigurationMRM789Test public void testGetConfigurationFromDefaultsWithDefaultRepoLocationAlreadyExisting() throws Exception { - File repo = new File( FileUtil.getBasedir(), "target/test-classes/existing_snapshots" ); - repo.mkdirs(); + Path repo = Paths.get( FileUtil.getBasedir(), "target/test-classes/existing_snapshots" ); + Files.createDirectories(repo); - repo = new File( FileUtil.getBasedir(), "target/test-classes/existing_internal" ); - repo.mkdirs(); + repo = Paths.get( FileUtil.getBasedir(), "target/test-classes/existing_internal" ); + Files.createDirectories(repo); String existingTestDefaultArchivaConfigFile = FileUtils.readFileToString( - getTestFile( "target/test-classes/org/apache/archiva/configuration/test-default-archiva.xml" ) ); + getTestFile( "target/test-classes/org/apache/archiva/configuration/test-default-archiva.xml" ).toFile(), FILE_ENCODING ); existingTestDefaultArchivaConfigFile = StringUtils.replace( existingTestDefaultArchivaConfigFile, "${appserver.base}", FileUtil.getBasedir() ); - File generatedTestDefaultArchivaConfigFile = new File( FileUtil.getBasedir(), + Path generatedTestDefaultArchivaConfigFile = Paths.get( FileUtil.getBasedir(), "target/test-classes/org/apache/archiva/configuration/default-archiva.xml" ); - FileUtils.writeStringToFile( generatedTestDefaultArchivaConfigFile, existingTestDefaultArchivaConfigFile, - Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( generatedTestDefaultArchivaConfigFile.toFile(), existingTestDefaultArchivaConfigFile, + Charset.forName(FILE_ENCODING) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-defaults-default-repo-location-exists" ); @@ -87,8 +91,8 @@ public class ArchivaConfigurationMRM789Test ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get( 0 ); assertTrue( "check managed repositories", repository.getLocation().endsWith( "data/repositories/internal" ) ); - generatedTestDefaultArchivaConfigFile.delete(); - assertFalse( generatedTestDefaultArchivaConfigFile.exists() ); + Files.deleteIfExists(generatedTestDefaultArchivaConfigFile); + assertFalse( Files.exists(generatedTestDefaultArchivaConfigFile) ); } diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java index 15080d873..1cc64ccd2 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java @@ -34,8 +34,10 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import javax.inject.Inject; -import java.io.File; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.List; import java.util.Map; @@ -59,9 +61,9 @@ public class ArchivaConfigurationTest @Inject FileTypes filetypes; - public static File getTestFile( String path ) + public static Path getTestFile( String path ) { - return new File( FileUtil.getBasedir(), path ); + return Paths.get( FileUtil.getBasedir(), path ); } protected T lookup( Class clazz, String hint ) @@ -197,9 +199,9 @@ public class ArchivaConfigurationTest public void testStoreConfiguration() throws Exception { - File file = getTestFile( "target/test/test-file.xml" ); - file.delete(); - assertFalse( file.exists() ); + Path file = getTestFile( "target/test/test-file.xml" ); + Files.deleteIfExists(file); + assertFalse( Files.exists(file) ); // TODO: remove with commons-configuration 1.4 //file.getParentFile().mkdirs(); @@ -228,7 +230,7 @@ public class ArchivaConfigurationTest verify( listener ); - assertTrue( "Check file exists", file.exists() ); + assertTrue( "Check file exists", Files.exists(file) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -251,16 +253,16 @@ public class ArchivaConfigurationTest public void testStoreConfigurationUser() throws Exception { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + Path baseFile = getTestFile( "target/test/test-file.xml" ); + Files.deleteIfExists( baseFile ); + assertFalse( Files.exists(baseFile) ); - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + Path userFile = getTestFile( "target/test/test-file-user.xml" ); + Files.deleteIfExists( userFile ); + assertFalse( Files.exists(userFile) ); - userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "", Charset.forName( "UTF-8" ) ); + Files.createDirectories(userFile.getParent()); + FileUtils.writeStringToFile( userFile.toFile(), "", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); @@ -271,8 +273,8 @@ public class ArchivaConfigurationTest archivaConfiguration.save( configuration ); - assertTrue( "Check file exists", userFile.exists() ); - assertFalse( "Check file not created", baseFile.exists() ); + assertTrue( "Check file exists", Files.exists(userFile) ); + assertFalse( "Check file not created", Files.exists(baseFile) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -283,13 +285,13 @@ public class ArchivaConfigurationTest public void testStoreConfigurationLoadedFromDefaults() throws Exception { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + Path baseFile = getTestFile( "target/test/test-file.xml" ); + Files.delete(baseFile); + assertFalse( Files.exists(baseFile) ); - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + Path userFile = getTestFile( "target/test/test-file-user.xml" ); + Files.deleteIfExists(userFile); + assertFalse( Files.exists(userFile) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user-defaults" ); @@ -312,8 +314,8 @@ public class ArchivaConfigurationTest verify( listener ); - assertTrue( "Check file exists", userFile.exists() ); - assertFalse( "Check file not created", baseFile.exists() ); + assertTrue( "Check file exists", Files.exists(userFile) ); + assertFalse( "Check file not created", Files.exists(baseFile) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -339,16 +341,16 @@ public class ArchivaConfigurationTest public void testStoreConfigurationFallback() throws Exception { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + Path baseFile = getTestFile( "target/test/test-file.xml" ); + Files.deleteIfExists(baseFile); + assertFalse( Files.exists(baseFile) ); - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + Path userFile = getTestFile( "target/test/test-file-user.xml" ); + Files.deleteIfExists(userFile); + assertFalse( Files.exists(userFile) ); - baseFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( baseFile, "", Charset.forName( "UTF-8" ) ); + Files.createDirectories( baseFile.getParent()); + FileUtils.writeStringToFile( baseFile.toFile(), "", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user-fallback" ); @@ -362,8 +364,8 @@ public class ArchivaConfigurationTest archivaConfiguration.save( configuration ); - assertTrue( "Check file exists", baseFile.exists() ); - assertFalse( "Check file not created", userFile.exists() ); + assertTrue( "Check file exists", Files.exists(baseFile) ); + assertFalse( "Check file not created", Files.exists(userFile) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -374,19 +376,19 @@ public class ArchivaConfigurationTest public void testStoreConfigurationFailsWhenReadFromBothLocationsNoLists() throws Exception { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + Path baseFile = getTestFile( "target/test/test-file.xml" ); + Files.deleteIfExists(baseFile); + assertFalse( Files.exists(baseFile) ); - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + Path userFile = getTestFile( "target/test/test-file-user.xml" ); + Files.deleteIfExists(userFile); + assertFalse( Files.exists(userFile) ); - baseFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( baseFile, "", Charset.forName( "UTF-8" ) ); + Files.createDirectories( baseFile.getParent() ); + FileUtils.writeStringToFile( baseFile.toFile(), "", Charset.forName( "UTF-8" ) ); - userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "", Charset.forName( "UTF-8" ) ); + Files.createDirectories( userFile.getParent()); + FileUtils.writeStringToFile( userFile.toFile(), "", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); @@ -399,12 +401,12 @@ public class ArchivaConfigurationTest archivaConfiguration.save( configuration ); - assertTrue( "Check file exists", baseFile.exists() ); + assertTrue( "Check file exists", Files.exists(baseFile) ); assertEquals( "Check base file is unchanged", "", - FileUtils.readFileToString( baseFile, Charset.forName( "UTF-8" ) ) ); - assertTrue( "Check file exists", userFile.exists() ); + FileUtils.readFileToString( baseFile.toFile(), Charset.forName( "UTF-8" ) ) ); + assertTrue( "Check file exists", Files.exists(userFile) ); assertFalse( "Check base file is changed", - "".equals( FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) ) ) ); + "".equals( FileUtils.readFileToString( userFile.toFile(), Charset.forName( "UTF-8" ) ) ) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -415,19 +417,19 @@ public class ArchivaConfigurationTest public void testStoreConfigurationFailsWhenReadFromBothLocationsUserHasLists() throws Exception { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + Path baseFile = getTestFile( "target/test/test-file.xml" ); + Files.deleteIfExists(baseFile); + assertFalse( Files.exists(baseFile) ); - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + Path userFile = getTestFile( "target/test/test-file-user.xml" ); + Files.deleteIfExists(userFile); + assertFalse( Files.exists(userFile) ); - userFile.getParentFile().mkdirs(); - FileUtils.copyFile( getTestFile( "src/test/conf/conf-user.xml" ), userFile ); + Files.createDirectories( userFile.getParent() ); + FileUtils.copyFile( getTestFile( "src/test/conf/conf-user.xml" ).toFile(), userFile.toFile() ); - baseFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( baseFile, "", Charset.forName( "UTF-8" ) ); + Files.createDirectories(baseFile.getParent()); + FileUtils.writeStringToFile( baseFile.toFile(), "", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); @@ -440,12 +442,12 @@ public class ArchivaConfigurationTest archivaConfiguration.save( configuration ); - assertTrue( "Check file exists", baseFile.exists() ); + assertTrue( "Check file exists", Files.exists(baseFile) ); assertEquals( "Check base file is unchanged", "", - FileUtils.readFileToString( baseFile, Charset.forName( "UTF-8" ) ) ); - assertTrue( "Check file exists", userFile.exists() ); + FileUtils.readFileToString( baseFile.toFile(), Charset.forName( "UTF-8" ) ) ); + assertTrue( "Check file exists", Files.exists(userFile) ); assertFalse( "Check base file is changed", - "".equals( FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) ) ) ); + "".equals( FileUtils.readFileToString( userFile.toFile(), Charset.forName( "UTF-8" ) ) ) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -456,19 +458,19 @@ public class ArchivaConfigurationTest public void testStoreConfigurationFailsWhenReadFromBothLocationsAppserverHasLists() throws Exception { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + Path baseFile = getTestFile( "target/test/test-file.xml" ); + Files.deleteIfExists(baseFile); + assertFalse( Files.exists(baseFile) ); - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + Path userFile = getTestFile( "target/test/test-file-user.xml" ); + Files.deleteIfExists(userFile); + assertFalse( Files.exists(userFile) ); - baseFile.getParentFile().mkdirs(); - FileUtils.copyFile( getTestFile( "src/test/conf/conf-base.xml" ), baseFile ); + Files.createDirectories(baseFile.getParent()); + FileUtils.copyFile( getTestFile( "src/test/conf/conf-base.xml" ).toFile(), baseFile.toFile() ); - userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "", Charset.forName( "UTF-8" ) ); + Files.createDirectories(userFile.getParent()); + FileUtils.writeStringToFile( userFile.toFile(), "", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); @@ -515,8 +517,8 @@ public class ArchivaConfigurationTest public void testLoadConfigurationFromInvalidUserLocationOnDisk() throws Exception { - File testConfDir = getTestFile( "target/test-appserver-base/conf/" ); - testConfDir.mkdirs(); + Path testConfDir = getTestFile( "target/test-appserver-base/conf/" ); + Files.createDirectories( testConfDir ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-not-allowed-to-write-to-user" ); @@ -587,12 +589,12 @@ public class ArchivaConfigurationTest throws Exception { // Setup the autodetect-v1.xml file in the target directory (so we can save/load it) - File userFile = getTestFile( "target/test-autodetect-v1/archiva-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + Path userFile = getTestFile( "target/test-autodetect-v1/archiva-user.xml" ); + Files.deleteIfExists(userFile); + assertFalse( Files.exists(userFile) ); - userFile.getParentFile().mkdirs(); - FileUtils.copyFile( getTestFile( "src/test/conf/autodetect-v1.xml" ), userFile ); + Files.createDirectories(userFile.getParent()); + FileUtils.copyFile( getTestFile( "src/test/conf/autodetect-v1.xml" ).toFile(), userFile.toFile()); // Load the original (unconverted) archiva.xml ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-autodetect-v1" ); @@ -631,7 +633,7 @@ public class ArchivaConfigurationTest assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() ); assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); - String actualXML = FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) ); + String actualXML = FileUtils.readFileToString( userFile.toFile(), Charset.forName( "UTF-8" ) ); XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML ); XMLAssert.assertXpathNotExists( "//configuration/repositories", actualXML ); } @@ -674,19 +676,19 @@ public class ArchivaConfigurationTest public void testCronExpressionsWithComma() throws Exception { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + Path baseFile = getTestFile( "target/test/test-file.xml" ); + Files.deleteIfExists(baseFile); + assertFalse( Files.exists(baseFile) ); - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + Path userFile = getTestFile( "target/test/test-file-user.xml" ); + Files.deleteIfExists(userFile); + assertFalse( Files.exists(userFile) ); - baseFile.getParentFile().mkdirs(); - FileUtils.copyFile( getTestFile( "src/test/conf/escape-cron-expressions.xml" ), baseFile ); + Files.createDirectories(baseFile.getParent()); + FileUtils.copyFile( getTestFile( "src/test/conf/escape-cron-expressions.xml" ).toFile(), baseFile.toFile() ); - userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "", Charset.defaultCharset() ); + Files.createDirectories(userFile.getParent()); + FileUtils.writeStringToFile( userFile.toFile(), "", Charset.defaultCharset() ); final ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-cron-expressions" ); @@ -728,19 +730,19 @@ public class ArchivaConfigurationTest public void testRemoveLastElements() throws Exception { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + Path baseFile = getTestFile( "target/test/test-file.xml" ); + Files.deleteIfExists(baseFile); + assertFalse( Files.exists(baseFile) ); - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + Path userFile = getTestFile( "target/test/test-file-user.xml" ); + Files.deleteIfExists(userFile); + assertFalse( Files.exists(userFile) ); - baseFile.getParentFile().mkdirs(); - FileUtils.copyFile( getTestFile( "src/test/conf/conf-single-list-elements.xml" ), baseFile ); + Files.createDirectories( baseFile.getParent() ); + FileUtils.copyFile( getTestFile( "src/test/conf/conf-single-list-elements.xml" ).toFile(), baseFile.toFile() ); - userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "", Charset.forName( "UTF-8" ) ); + Files.createDirectories( userFile.getParent()); + FileUtils.writeStringToFile( userFile.toFile(), "", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-remove-central" ); diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/MavenProxyPropertyLoaderTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/MavenProxyPropertyLoaderTest.java index 0b6ffc2a8..5e620bcbf 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/MavenProxyPropertyLoaderTest.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/MavenProxyPropertyLoaderTest.java @@ -19,10 +19,9 @@ package org.apache.archiva.configuration; * under the License. */ -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.util.Map; import java.util.Properties; import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; @@ -42,14 +41,14 @@ public class MavenProxyPropertyLoaderTest public void testLoadValidMavenProxyConfiguration() throws IOException, InvalidConfigurationException { - File confFile = ArchivaConfigurationTest.getTestFile( "src/test/conf/maven-proxy-complete.conf" ); + Path confFile = ArchivaConfigurationTest.getTestFile( "src/test/conf/maven-proxy-complete.conf" ); Configuration configuration = new Configuration(); NetworkProxyConfiguration proxy = new NetworkProxyConfiguration(); proxy.setHost( "original-host" ); configuration.addNetworkProxy( proxy ); // overwritten - loader.load( Files.newInputStream(confFile.toPath()), configuration ); + loader.load( Files.newInputStream(confFile), configuration ); Map repositoryIdMap = configuration.getManagedRepositoriesAsMap(); assertEquals( "Count repositories", 1, repositoryIdMap.size() );