From 98715c57ea3dd35ab1cb44ea7a2ccd6397dc25c7 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Fri, 8 Sep 2017 10:06:01 +0200 Subject: [PATCH] Migrating xmltools and proxy to java.nio --- .../maven2/metadata/MavenMetadataReader.java | 2 +- .../DefaultRepositoryProxyConnectors.java | 29 ++-------- .../archiva/proxy/AbstractProxyTestCase.java | 53 +++++++++---------- .../archiva/proxy/ChecksumTransferTest.java | 1 - .../archiva/proxy/MetadataTransferTest.java | 8 +-- .../apache/archiva/proxy/WagonDelegate.java | 20 +++---- .../org/apache/archiva/xml/XMLReader.java | 34 +++++------- .../xml/AbstractArchivaXmlTestCase.java | 20 +++---- .../xml/LatinEntityResolutionReaderTest.java | 18 +++---- .../org/apache/archiva/xml/XMLReaderTest.java | 14 ++--- 10 files changed, 81 insertions(+), 118 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-maven2-metadata/src/main/java/org/apache/archiva/maven2/metadata/MavenMetadataReader.java b/archiva-modules/archiva-base/archiva-maven2-metadata/src/main/java/org/apache/archiva/maven2/metadata/MavenMetadataReader.java index 22eb836e9..023b8eaa2 100644 --- a/archiva-modules/archiva-base/archiva-maven2-metadata/src/main/java/org/apache/archiva/maven2/metadata/MavenMetadataReader.java +++ b/archiva-modules/archiva-base/archiva-maven2-metadata/src/main/java/org/apache/archiva/maven2/metadata/MavenMetadataReader.java @@ -75,7 +75,7 @@ public class MavenMetadataReader throws XMLException { - XMLReader xml = new XMLReader( "metadata", metadataFile.toFile() ); + XMLReader xml = new XMLReader( "metadata", metadataFile ); // invoke this to remove namespaces, see MRM-1136 xml.removeNamespaces(); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java index dc100f0ca..e4e60fe73 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java @@ -28,22 +28,11 @@ import org.apache.archiva.common.filelock.FileLockException; import org.apache.archiva.common.filelock.FileLockManager; import org.apache.archiva.common.filelock.FileLockTimeoutException; import org.apache.archiva.common.filelock.Lock; -import org.apache.archiva.configuration.ArchivaConfiguration; -import org.apache.archiva.configuration.Configuration; -import org.apache.archiva.configuration.ConfigurationNames; -import org.apache.archiva.configuration.NetworkProxyConfiguration; -import org.apache.archiva.configuration.ProxyConnectorConfiguration; -import org.apache.archiva.configuration.ProxyConnectorRuleConfiguration; +import org.apache.archiva.configuration.*; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.Keys; import org.apache.archiva.model.RepositoryURL; -import org.apache.archiva.policies.DownloadErrorPolicy; -import org.apache.archiva.policies.DownloadPolicy; -import org.apache.archiva.policies.PolicyConfigurationException; -import org.apache.archiva.policies.PolicyViolationException; -import org.apache.archiva.policies.PostDownloadPolicy; -import org.apache.archiva.policies.PreDownloadPolicy; -import org.apache.archiva.policies.ProxyDownloadException; +import org.apache.archiva.policies.*; import org.apache.archiva.policies.urlcache.UrlFailureCache; import org.apache.archiva.proxy.common.WagonFactory; import org.apache.archiva.proxy.common.WagonFactoryException; @@ -54,11 +43,7 @@ import org.apache.archiva.proxy.model.RepositoryProxyConnectors; import org.apache.archiva.redback.components.registry.Registry; import org.apache.archiva.redback.components.registry.RegistryListener; import org.apache.archiva.redback.components.taskqueue.TaskQueueException; -import org.apache.archiva.repository.ManagedRepositoryContent; -import org.apache.archiva.repository.RemoteRepositoryContent; -import org.apache.archiva.repository.RepositoryContentFactory; -import org.apache.archiva.repository.RepositoryException; -import org.apache.archiva.repository.RepositoryNotFoundException; +import org.apache.archiva.repository.*; import org.apache.archiva.repository.metadata.MetadataTools; import org.apache.archiva.repository.metadata.RepositoryMetadataException; import org.apache.archiva.scheduler.ArchivaTaskScheduler; @@ -84,18 +69,12 @@ 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.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java index 124e7a58b..a8ffb6336 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java @@ -53,7 +53,6 @@ import org.springframework.test.context.ContextConfiguration; import javax.inject.Inject; import java.io.BufferedReader; -import java.io.File; import java.io.FileReader; import java.io.IOException; import java.nio.charset.Charset; @@ -63,12 +62,9 @@ import java.nio.file.Paths; import java.nio.file.attribute.FileTime; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.Locale; +import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import static org.junit.Assert.*; @@ -168,11 +164,11 @@ public abstract class AbstractProxyTestCase // Setup target (proxied to) repository. saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1", - new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" ); + Paths.get( REPOPATH_PROXIED1 ).toUri().toURL().toExternalForm(), "default" ); // Setup target (proxied to) repository. saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2", - new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" ); + Paths.get( REPOPATH_PROXIED2 ).toUri().toURL().toExternalForm(), "default" ); // Setup the proxy handler. //proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() ); @@ -270,15 +266,19 @@ public abstract class AbstractProxyTestCase return; } - Collection tmpFiles = - org.apache.commons.io.FileUtils.listFiles( workingDir.toFile(), new String[]{ "tmp" }, false ); - if ( !tmpFiles.isEmpty() ) + Collection tmpFiles = null; + try { + tmpFiles = Files.list(workingDir).filter(path -> Files.isRegularFile(path) && path.getFileName().toString().endsWith(".tmp")).collect(Collectors.toList()); + } catch (IOException e) { + log.error("Could not retrieve tmpFiles {}", workingDir); + } + if ( tmpFiles!=null && !tmpFiles.isEmpty() ) { StringBuilder emsg = new StringBuilder(); emsg.append( "Found Temp Files in dir: " ).append( workingDir.toString() ); - for ( File tfile : tmpFiles ) + for ( Path tfile : tmpFiles ) { - emsg.append( "\n " ).append( tfile.getName() ); + emsg.append( "\n " ).append( tfile.getFileName().toString()); } fail( emsg.toString() ); } @@ -300,44 +300,43 @@ public abstract class AbstractProxyTestCase throw new IOException( "Source directory doesn't exists (" + sourceDirectory.toAbsolutePath() + ")." ); } - File[] files = sourceDirectory.toFile().listFiles(); + Path[] files = Files.list(sourceDirectory).filter(path -> Files.isRegularFile(path)).toArray(Path[]::new); String sourcePath = sourceDirectory.toAbsolutePath().toString(); for ( int i = 0; i < files.length; i++ ) { - File file = files[i]; + Path file = files[i]; - String dest = file.getAbsolutePath(); + String dest = file.toAbsolutePath().toString(); dest = dest.substring( sourcePath.length() + 1 ); - File destination = new File( destDirectory.toFile(), dest ); + Path destination = destDirectory.resolve( dest ); - if ( file.isFile() ) + if ( Files.isRegularFile(file) ) { - destination = destination.getParentFile(); + destination = destination.getParent(); - org.apache.commons.io.FileUtils.copyFile( file, new File( destination, file.getName() ), false ); + org.apache.commons.io.FileUtils.copyFile( file.toFile(), destination.resolve( file.getFileName() ).toFile(), false ); // TODO: Change when there is a FileUtils.copyFileToDirectory(file, destination, boolean) option //FileUtils.copyFileToDirectory( file, destination ); } - else if ( file.isDirectory() ) + else if ( Files.isDirectory(file) ) { - if ( !".svn".equals( file.getName() ) ) + if ( !".svn".equals( file.getFileName().toString() ) ) { - if ( !destination.exists() && !destination.mkdirs() ) + if ( !Files.exists(destination)) { - throw new IOException( - "Could not create destination directory '" + destination.getAbsolutePath() + "'." ); + Files.createDirectories(destination); } - copyDirectoryStructure( file.toPath(), destination.toPath() ); + copyDirectoryStructure( file, destination ); } } else { - throw new IOException( "Unknown file type: " + file.getAbsolutePath() ); + throw new IOException( "Unknown file type: " + file.toAbsolutePath() ); } } } diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java index 51e53e765..e9ade0479 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java @@ -30,7 +30,6 @@ import org.easymock.EasyMock; import org.junit.Test; import java.io.File; -import java.nio.file.CopyOption; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java index 7d453540d..b9a5f1ac3 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java @@ -22,21 +22,15 @@ package org.apache.archiva.proxy; import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.maven2.metadata.MavenMetadataReader; -import org.apache.archiva.model.ArchivaRepositoryMetadata; -import org.apache.archiva.model.Plugin; -import org.apache.archiva.model.ProjectReference; -import org.apache.archiva.model.SnapshotVersion; -import org.apache.archiva.model.VersionedReference; +import org.apache.archiva.model.*; import org.apache.archiva.policies.CachedFailuresPolicy; import org.apache.archiva.policies.ChecksumPolicy; import org.apache.archiva.policies.ReleasesPolicy; import org.apache.archiva.policies.SnapshotsPolicy; -import org.apache.archiva.proxy.model.ProxyFetchResult; import org.apache.archiva.repository.metadata.MetadataTools; import org.apache.archiva.repository.metadata.RepositoryMetadataException; import org.apache.archiva.repository.metadata.RepositoryMetadataWriter; import org.apache.commons.lang.StringUtils; -import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.custommonkey.xmlunit.DetailedDiff; import org.custommonkey.xmlunit.Diff; diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/WagonDelegate.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/WagonDelegate.java index 56edc448d..702fe99c7 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/WagonDelegate.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/WagonDelegate.java @@ -19,7 +19,6 @@ package org.apache.archiva.proxy; * under the License. */ -import org.apache.commons.io.FileUtils; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; @@ -39,6 +38,8 @@ import org.springframework.stereotype.Service; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.List; /** @@ -60,7 +61,7 @@ public class WagonDelegate { log.debug( ".get({}, {})", resourceName, destination ); delegate.get( resourceName, destination ); - create( destination ); + create( destination.toPath() ); } @Override @@ -70,7 +71,7 @@ public class WagonDelegate log.info( ".getIfNewer({}, {}, {})", resourceName, destination, timestamp ); boolean result = delegate.getIfNewer( resourceName, destination, timestamp ); - createIfMissing( destination ); + createIfMissing( destination.toPath() ); return result; } @@ -254,28 +255,27 @@ public class WagonDelegate contentToGet = content; } - private void createIfMissing( File destination ) + private void createIfMissing( Path destination ) { // since the mock won't actually copy a file, create an empty one to simulate file existence - if ( !destination.exists() ) + if ( !Files.exists(destination) ) { create( destination ); } } - private void create( File destination ) + private void create( Path destination ) { try { - destination.getParentFile().mkdirs(); + Files.createDirectories(destination.getParent()); if ( contentToGet == null ) { - destination.createNewFile(); + Files.createFile(destination); } else { - FileUtils.writeStringToFile( new File( destination.getAbsolutePath() ), contentToGet, - Charset.defaultCharset() ); + org.apache.archiva.common.utils.FileUtils.writeStringToFile(destination, Charset.defaultCharset(), contentToGet); } } catch ( IOException e ) diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/XMLReader.java b/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/XMLReader.java index d889e92d8..5d3f1cd0e 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/XMLReader.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/XMLReader.java @@ -20,28 +20,18 @@ package org.apache.archiva.xml; */ import org.apache.commons.lang.StringUtils; -import org.dom4j.Attribute; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.dom4j.Namespace; -import org.dom4j.Node; -import org.dom4j.QName; -import org.dom4j.XPath; +import org.dom4j.*; import org.dom4j.io.SAXReader; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.*; /** * XMLReader - a set of common xml utility methods for reading content out of an xml file. @@ -56,27 +46,27 @@ public class XMLReader private Map namespaceMap = new HashMap<>(); - public XMLReader( String type, File file ) + public XMLReader( String type, Path file ) throws XMLException { - if ( !file.exists() ) + if ( !Files.exists(file) ) { - throw new XMLException( "file does not exist: " + file.getAbsolutePath() ); + throw new XMLException( "file does not exist: " + file.toAbsolutePath() ); } - if ( !file.isFile() ) + if ( !Files.isRegularFile(file) ) { - throw new XMLException( "path is not a file: " + file.getAbsolutePath() ); + throw new XMLException( "path is not a file: " + file.toAbsolutePath() ); } - if ( !file.canRead() ) + if ( !Files.isReadable(file) ) { - throw new XMLException( "Cannot read xml file due to permissions: " + file.getAbsolutePath() ); + throw new XMLException( "Cannot read xml file due to permissions: " + file.toAbsolutePath() ); } try { - init( type, file.toURL() ); + init( type, file.toUri().toURL() ); } catch ( MalformedURLException e ) { diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/AbstractArchivaXmlTestCase.java b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/AbstractArchivaXmlTestCase.java index 5f340053f..83155b453 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/AbstractArchivaXmlTestCase.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/AbstractArchivaXmlTestCase.java @@ -19,12 +19,14 @@ package org.apache.archiva.xml; * under the License. */ -import java.io.File; - import junit.framework.TestCase; import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; import org.junit.runner.RunWith; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + /** * AbstractArchivaXmlTestCase * @@ -42,17 +44,17 @@ public abstract class AbstractArchivaXmlTestCase protected static final String INFINITE_ARCHIVA = "The " + INFIN + " Archiva"; - protected File getExampleXml( String filename ) + protected Path getExampleXml(String filename ) { - File examplesDir = new File( "src/test/examples" ); - if ( !examplesDir.exists() ) + Path examplesDir = Paths.get("src/test/examples"); + if ( !Files.exists(examplesDir) ) { - fail( "Missing the examples directory: " + examplesDir.getAbsolutePath() ); + fail( "Missing the examples directory: " + examplesDir.toAbsolutePath() ); } - File exampleFile = new File( examplesDir, filename ); - if ( !exampleFile.exists() ) + Path exampleFile = examplesDir.resolve( filename ); + if ( !Files.exists(exampleFile) ) { - fail( "Missing the example xml file: " + exampleFile.getAbsolutePath() ); + fail( "Missing the example xml file: " + exampleFile.toAbsolutePath() ); } return exampleFile; } diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/LatinEntityResolutionReaderTest.java b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/LatinEntityResolutionReaderTest.java index b97e828fb..c3c7dd0de 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/LatinEntityResolutionReaderTest.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/LatinEntityResolutionReaderTest.java @@ -25,7 +25,6 @@ import org.junit.Assert; import org.junit.Test; import java.io.BufferedReader; -import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; @@ -34,6 +33,7 @@ import java.io.Reader; import java.io.StringWriter; import java.net.URL; import java.nio.charset.Charset; +import java.nio.file.Path; /** * LatinEntityResolutionReaderTest @@ -79,8 +79,8 @@ public class LatinEntityResolutionReaderTest private String toStringFromExample( String examplePath ) throws IOException { - File exampleFile = getExampleXml( examplePath ); - FileReader fileReader = new FileReader( exampleFile ); + Path exampleFile = getExampleXml( examplePath ); + FileReader fileReader = new FileReader( exampleFile.toFile() ); BufferedReader lineReader = new BufferedReader( fileReader ); StringBuilder sb = new StringBuilder(); @@ -105,9 +105,9 @@ public class LatinEntityResolutionReaderTest { try { - File inputFile = getExampleXml( sourcePath ); + Path inputFile = getExampleXml( sourcePath ); - FileReader fileReader = new FileReader( inputFile ); + FileReader fileReader = new FileReader( inputFile.toFile() ); LatinEntityResolutionReader testReader = new LatinEntityResolutionReader( fileReader ); String actualOutput = toStringFromReader( testReader, bufsize ); @@ -125,9 +125,9 @@ public class LatinEntityResolutionReaderTest { try { - File inputFile = getExampleXml( sourcePath ); + Path inputFile = getExampleXml( sourcePath ); - FileReader fileReader = new FileReader( inputFile ); + FileReader fileReader = new FileReader( inputFile.toFile() ); LatinEntityResolutionReader testReader = new LatinEntityResolutionReader( fileReader ); String actualOutput = toStringFromReader( testReader, bufSize ); @@ -208,11 +208,11 @@ public class LatinEntityResolutionReaderTest public void testReaderLeftOver() throws IOException { - File inputFile = getExampleXml( "maven-metadata-leftover.xml" ); + Path inputFile = getExampleXml( "maven-metadata-leftover.xml" ); //Bits from RepositoryMetadataReader.read InputStream in = null; SAXReader reader = new SAXReader(); - URL url = inputFile.toURL(); + URL url = inputFile.toUri().toURL(); in = url.openStream(); InputStreamReader inReader = new InputStreamReader( in, Charset.forName( "UTF-8" ) ); LatinEntityResolutionReader latinReader = new LatinEntityResolutionReader( inReader ); diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/XMLReaderTest.java b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/XMLReaderTest.java index 05c9855f2..fa99a4afa 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/XMLReaderTest.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/archiva/xml/XMLReaderTest.java @@ -19,7 +19,7 @@ package org.apache.archiva.xml; * under the License. */ -import java.io.File; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -55,7 +55,7 @@ public class XMLReaderTest public void testNoPrologBasicRead() throws XMLException { - File xmlFile = getExampleXml( "no-prolog-basic.xml" ); + Path xmlFile = getExampleXml( "no-prolog-basic.xml" ); XMLReader reader = new XMLReader( "basic", xmlFile ); List fruits = reader.getElementList( "//basic/fruits/fruit" ); @@ -66,7 +66,7 @@ public class XMLReaderTest public void testNoPrologEntitiesRead() throws XMLException { - File xmlFile = getExampleXml( "no-prolog-with-entities.xml" ); + Path xmlFile = getExampleXml( "no-prolog-with-entities.xml" ); XMLReader reader = new XMLReader( "basic", xmlFile ); List names = reader.getElementList( "//basic/names/name" ); @@ -77,7 +77,7 @@ public class XMLReaderTest public void testNoPrologUtf8Read() throws XMLException { - File xmlFile = getExampleXml( "no-prolog-with-utf8.xml" ); + Path xmlFile = getExampleXml( "no-prolog-with-utf8.xml" ); XMLReader reader = new XMLReader( "basic", xmlFile ); List names = reader.getElementList( "//basic/names/name" ); @@ -88,7 +88,7 @@ public class XMLReaderTest public void testPrologUtf8Read() throws XMLException { - File xmlFile = getExampleXml( "prolog-with-utf8.xml" ); + Path xmlFile = getExampleXml( "prolog-with-utf8.xml" ); XMLReader reader = new XMLReader( "basic", xmlFile ); List names = reader.getElementList( "//basic/names/name" ); @@ -100,8 +100,8 @@ public class XMLReaderTest public void testProxiedMetadataRead() throws XMLException { - File xmlFile = getExampleXml( "maven-metadata-codehaus-snapshots.xml" ); - XMLReader reader = new XMLReader( "metadata", xmlFile ); + Path xmlFile = getExampleXml( "maven-metadata-codehaus-snapshots.xml" ); + XMLReader reader = new XMLReader( "metadata", xmlFile ); reader.removeNamespaces(); Element groupId = reader.getElement( "//metadata/groupId" ); -- 2.39.5