You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/09/26 10:27:49 UTC
(maven-indexer) 01/02: Apply modernizer to test sources too
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-indexer.git
commit e98440853059b0b2f432c31088e1d82a5c91f97b
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Sep 26 01:35:40 2026 +0200
Apply modernizer to test sources too
---
.../index/cli/AbstractNexusIndexerCliTest.java | 33 ++++----
.../apache/maven/index/cli/NexusIndexerCliIT.java | 7 +-
.../maven/index/AbstractIndexCreatorHelper.java | 4 +-
.../maven/index/AbstractRepoNexusIndexerTest.java | 5 +-
.../apache/maven/index/AbstractTestSupport.java | 3 +-
.../org/apache/maven/index/ConcurrentUseTest.java | 3 +-
...ncurrentUseWithMergedContextPublishingTest.java | 10 ++-
.../maven/index/DefaultIndexNexusIndexerTest.java | 5 +-
.../maven/index/DefaultSearchEngineTest.java | 6 +-
.../apache/maven/index/DuplicateSearchTest.java | 3 +-
.../apache/maven/index/FSDirectoryDeleteTest.java | 3 +-
.../maven/index/FullIndexNexusIndexerTest.java | 5 +-
.../apache/maven/index/Mindexer14HitLimitTest.java | 3 +-
.../maven/index/Mindexer35NexusIndexerTest.java | 3 +-
.../maven/index/Nexus1179NexusIndexerTest.java | 3 +-
.../maven/index/Nexus13NexusIndexerTest.java | 10 ++-
.../index/Nexus1911IncrementalMergedCtxTest.java | 4 +-
.../maven/index/Nexus1911IncrementalTest.java | 37 +++++----
.../maven/index/Nexus2046NexusIndexerTest.java | 3 +-
.../maven/index/Nexus3177HitLimitChecks.java | 3 +-
.../maven/index/Nexus3233NexusIndexerTest.java | 3 +-
.../index/Nexus3293TimestampSnapshotTest.java | 26 ++++---
.../maven/index/Nexus3881NexusIndexerTest.java | 3 +-
.../maven/index/Nexus4674GavPathReindexTest.java | 9 ++-
.../maven/index/Nexus645NexusIndexerTest.java | 3 +-
.../maven/index/Nexus658NexusIndexerTest.java | 3 +-
.../maven/index/Nexus687NexusIndexerTest.java | 3 +-
.../maven/index/Nexus737NexusIndexerTest.java | 3 +-
.../org/apache/maven/index/NexusIndexerTest.java | 20 ++---
.../maven/index/SearchWithAnEmptyIndexTest.java | 14 ++--
.../org/apache/maven/index/SubPathReindexTest.java | 9 ++-
.../maven/index/UniqueArtifactFilterTest.java | 6 +-
.../creator/JarFileContentsIndexCreatorTest.java | 45 ++++++-----
.../MavenPluginArtifactInfoIndexCreatorTest.java | 15 ++--
.../creator/OsgiArtifactIndexCreatorTest.java | 43 ++++++-----
.../incremental/DefaultIncrementalHandlerTest.java | 9 ++-
.../maven/index/locator/ArtifactLocatorTest.java | 2 +-
.../index/packer/NEXUS4149TransferFormatTest.java | 52 ++++++++++---
.../maven/index/treeview/IndexTreeViewTest.java | 3 +-
.../index/updater/AbstractIndexUpdaterTest.java | 9 ++-
.../index/updater/DefaultIndexUpdaterTest.java | 15 ++--
.../updater/DownloadRemoteIndexerManagerTest.java | 19 +++--
.../maven/index/updater/LocalIndexCacheTest.java | 87 +++++++++++++++++-----
.../index/updater/fixtures/ServerTestFixture.java | 3 +-
.../apache/maven/index/util/SpoofIndexCreator.java | 3 +-
.../index/examples/SimpleArtifactGenerator.java | 32 ++++----
.../index/examples/SpringUsageExampleTest.java | 21 ++++--
.../index/examples/boot/RepositoryBooter.java | 24 ++++--
pom.xml | 2 -
49 files changed, 409 insertions(+), 230 deletions(-)
diff --git a/indexer-cli/src/test/java/org/apache/maven/index/cli/AbstractNexusIndexerCliTest.java b/indexer-cli/src/test/java/org/apache/maven/index/cli/AbstractNexusIndexerCliTest.java
index 0124dc18..0ba960e3 100644
--- a/indexer-cli/src/test/java/org/apache/maven/index/cli/AbstractNexusIndexerCliTest.java
+++ b/indexer-cli/src/test/java/org/apache/maven/index/cli/AbstractNexusIndexerCliTest.java
@@ -21,6 +21,7 @@ package org.apache.maven.index.cli;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
+import java.nio.file.Path;
import java.util.Random;
import org.codehaus.plexus.util.FileUtils;
@@ -38,22 +39,24 @@ public abstract class AbstractNexusIndexerCliTest extends InjectedTest {
private static final long rand = new Random().nextLong();
/*
- * private static final String DEST_DIR = new File( getBasedir(), "target/tests/clitest/output-"+rand
- * ).getAbsolutePath(); private static final String INDEX_DIR = new File( getBasedir(),
- * "target/tests/clitest/index-"+rand ).getAbsolutePath(); private static final String UNPACK_DIR = new File(
+ * private static final String DEST_DIR = Path.of(getBasedir(), "target/tests/clitest/output-"+rand *).toFile().getAbsolutePath(); private static final String INDEX_DIR = Path.of(getBasedir(), * "target/tests/clitest/index-"+rand).toFile().getAbsolutePath(); private static final String UNPACK_DIR = new File(
* getBasedir(), "target/tests/clitest/unpack-"+rand ).getAbsolutePath(); private static final String TEST_REPO =
- * new File( getBasedir(), "src/test/repo" ).getAbsolutePath();
+ * Path.of(getBasedir(), "src/test/repo").toFile().getAbsolutePath();
*/
- private final String DEST_DIR =
- new File(getBasedir(), "target/tests/clitest-" + rand + "/output").getAbsolutePath();
+ private final String DEST_DIR = Path.of(getBasedir(), "target/tests/clitest-" + rand + "/output")
+ .toFile()
+ .getAbsolutePath();
- private final String INDEX_DIR =
- new File(getBasedir(), "target/tests/clitest-" + rand + "/index").getAbsolutePath();
+ private final String INDEX_DIR = Path.of(getBasedir(), "target/tests/clitest-" + rand + "/index")
+ .toFile()
+ .getAbsolutePath();
- private final String UNPACK_DIR =
- new File(getBasedir(), "target/tests/clitest-" + rand + "/unpack").getAbsolutePath();
+ private final String UNPACK_DIR = Path.of(getBasedir(), "target/tests/clitest-" + rand + "/unpack")
+ .toFile()
+ .getAbsolutePath();
- private final String TEST_REPO = new File(getBasedir(), "src/test/repo").getAbsolutePath();
+ private final String TEST_REPO =
+ Path.of(getBasedir(), "src/test/repo").toFile().getAbsolutePath();
protected OutputStream out;
@@ -93,7 +96,7 @@ public abstract class AbstractNexusIndexerCliTest extends InjectedTest {
}
protected File getTestFile(String path) {
- return new File(new File(getBasedir()), path);
+ return Path.of(getBasedir(), path).toFile();
}
@Test
@@ -148,7 +151,7 @@ public abstract class AbstractNexusIndexerCliTest extends InjectedTest {
assertEquals(1, code, output);
assertTrue(output.contains(usage), "Should print bad usage but '" + output + "'");
- assertFalse(new File(INDEX_DIR).exists(), "Index file was generated");
+ assertFalse(Path.of(INDEX_DIR).toFile().exists(), "Index file was generated");
}
@Test
@@ -162,7 +165,9 @@ public abstract class AbstractNexusIndexerCliTest extends InjectedTest {
public void testInvalidRepo() throws Exception {
int code = execute(
"-r",
- new File("target/undexinting/repo/to/try/what/will/happen/here").getCanonicalPath(),
+ Path.of("target/undexinting/repo/to/try/what/will/happen/here")
+ .toFile()
+ .getCanonicalPath(),
"-i",
INDEX_DIR,
"-d",
diff --git a/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliIT.java b/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliIT.java
index 4c5b6fae..ad5a31f7 100644
--- a/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliIT.java
+++ b/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliIT.java
@@ -18,9 +18,9 @@
*/
package org.apache.maven.index.cli;
-import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
+import java.nio.file.Path;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -32,9 +32,10 @@ public class NexusIndexerCliIT extends AbstractNexusIndexerCliTest {
try {
Commandline cmd = new Commandline();
cmd.setExecutable("java");
- cmd.setWorkingDirectory(new File(".").getCanonicalFile());
+ cmd.setWorkingDirectory(Path.of(".").toFile().getCanonicalFile());
cmd.createArg().setValue("-jar");
- cmd.createArg().setValue(new File(System.getProperty("indexerJar")).getCanonicalPath());
+ cmd.createArg()
+ .setValue(Path.of(System.getProperty("indexerJar")).toFile().getCanonicalPath());
return cmd;
} catch (IOException e) {
throw new RuntimeException(e);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/AbstractIndexCreatorHelper.java b/indexer-core/src/test/java/org/apache/maven/index/AbstractIndexCreatorHelper.java
index e91b8d37..89c078f5 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/AbstractIndexCreatorHelper.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/AbstractIndexCreatorHelper.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -78,7 +79,8 @@ public class AbstractIndexCreatorHelper extends AbstractTestSupport {
protected File getDirectory(String name) {
// pick random output location
- File outputFolder = new File(getBasedir(), "target/tests/" + name + "-" + rand.nextLong() + "/");
+ File outputFolder = Path.of(getBasedir(), "target/tests/" + name + "-" + rand.nextLong() + "/")
+ .toFile();
outputFolder.delete();
assertFalse(outputFolder.exists());
return outputFolder;
diff --git a/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java
index 9934957b..06a9b068 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -41,7 +42,7 @@ import static org.junit.jupiter.api.Assertions.fail;
public abstract class AbstractRepoNexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/repo");
+ protected File repo = Path.of(getBasedir(), "src/test/repo").toFile();
@Test
public void testRootGroups() throws Exception {
@@ -395,7 +396,7 @@ public abstract class AbstractRepoNexusIndexerTest extends AbstractNexusIndexerT
// Using a file
- File artifact = new File(repo, "qdox/qdox/1.5/qdox-1.5.jar");
+ File artifact = repo.toPath().resolve("qdox/qdox/1.5/qdox-1.5.jar").toFile();
ais = nexusIndexer.identify(artifact);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/AbstractTestSupport.java b/indexer-core/src/test/java/org/apache/maven/index/AbstractTestSupport.java
index d23f815a..1caed4ee 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/AbstractTestSupport.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/AbstractTestSupport.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import org.eclipse.sisu.launch.InjectedTest;
@@ -27,6 +28,6 @@ import org.eclipse.sisu.launch.InjectedTest;
*/
public class AbstractTestSupport extends InjectedTest {
protected File getTestFile(String path) {
- return new File(new File(getBasedir()), path);
+ return Path.of(getBasedir(), path).toFile();
}
}
diff --git a/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseTest.java b/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseTest.java
index 17840b3a..b5c9bad4 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.search.Query;
@@ -35,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
public class ConcurrentUseTest extends AbstractNexusIndexerTest {
public static final int THREAD_COUNT = 10;
- protected File repo = new File(getBasedir(), "src/test/repo");
+ protected File repo = Path.of(getBasedir(), "src/test/repo").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java b/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java
index 2b655882..5556c715 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.search.IndexSearcher;
@@ -38,7 +39,7 @@ import org.junit.jupiter.api.BeforeEach;
public class ConcurrentUseWithMergedContextPublishingTest extends ConcurrentUseWithMergedContextTest {
protected IndexPacker packer;
- protected File repoPublish = new File(getBasedir(), "target/repo-publish");
+ protected File repoPublish = Path.of(getBasedir(), "target/repo-publish").toFile();
protected final AtomicInteger counter = new AtomicInteger();
@@ -53,7 +54,7 @@ public class ConcurrentUseWithMergedContextPublishingTest extends ConcurrentUseW
@AfterEach
@Override
public void tearDown() throws Exception {
- File props = new File(IndexingContext.INDEX_PACKER_PROPERTIES_FILE);
+ File props = Path.of(IndexingContext.INDEX_PACKER_PROPERTIES_FILE).toFile();
if (props.exists()) {
props.delete();
}
@@ -66,7 +67,10 @@ public class ConcurrentUseWithMergedContextPublishingTest extends ConcurrentUseW
// This test had multiple threads doing it, and since it was not checking actual results of publish (that was
// not the goal of the test, but simultaneous publishing of merged context that has member changes happening),
// it was probably publish rubbish anyway.
- final File publish = new File(repoPublish, "publish-" + counter.getAndIncrement());
+ final File publish = repoPublish
+ .toPath()
+ .resolve("publish-" + counter.getAndIncrement())
+ .toFile();
final IndexSearcher indexSearcher = context.acquireIndexSearcher();
try {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/DefaultIndexNexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/DefaultIndexNexusIndexerTest.java
index b48c981c..438998cf 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/DefaultIndexNexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/DefaultIndexNexusIndexerTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -158,7 +159,7 @@ public class DefaultIndexNexusIndexerTest extends MinimalIndexNexusIndexerTest {
Thread.sleep(1000L);
- File newIndex = new File(getBasedir(), "target/test-new");
+ File newIndex = Path.of(getBasedir(), "target/test-new").toFile();
Directory newIndexDir = FSDirectory.open(newIndex.toPath());
@@ -215,7 +216,7 @@ public class DefaultIndexNexusIndexerTest extends MinimalIndexNexusIndexerTest {
newContext.close(true);
- assertFalse(new File(newIndex, "timestamp").exists());
+ assertFalse(newIndex.toPath().resolve("timestamp").toFile().exists());
}
@Test
diff --git a/indexer-core/src/test/java/org/apache/maven/index/DefaultSearchEngineTest.java b/indexer-core/src/test/java/org/apache/maven/index/DefaultSearchEngineTest.java
index ce960439..d4f08e59 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/DefaultSearchEngineTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/DefaultSearchEngineTest.java
@@ -20,7 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
-import java.util.Collections;
+import java.nio.file.Path;
import java.util.List;
import org.apache.lucene.search.IndexSearcher;
@@ -82,7 +82,7 @@ public class DefaultSearchEngineTest extends AbstractNexusIndexerTest {
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
- File repo = new File(getBasedir(), "src/test/repo");
+ File repo = Path.of(getBasedir(), "src/test/repo").toFile();
context = new CountingIndexingContext(
"test-minimal", "test", repo, indexDir, null, null, IndexCreatorSorter.sort(MIN_CREATORS), false);
@@ -118,7 +118,7 @@ public class DefaultSearchEngineTest extends AbstractNexusIndexerTest {
});
try {
- searchEngine.forceSearchIteratorPaged(request, Collections.singletonList(context));
+ searchEngine.forceSearchIteratorPaged(request, List.of(context));
} catch (RuntimeException e) {
// this is the point of this test
}
diff --git a/indexer-core/src/test/java/org/apache/maven/index/DuplicateSearchTest.java b/indexer-core/src/test/java/org/apache/maven/index/DuplicateSearchTest.java
index ef0aa1ea..5893631e 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/DuplicateSearchTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/DuplicateSearchTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashSet;
@@ -34,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class DuplicateSearchTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/repo");
+ protected File repo = Path.of(getBasedir(), "src/test/repo").toFile();
protected IndexingContext context1;
diff --git a/indexer-core/src/test/java/org/apache/maven/index/FSDirectoryDeleteTest.java b/indexer-core/src/test/java/org/apache/maven/index/FSDirectoryDeleteTest.java
index a04e3883..8dbb8174 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/FSDirectoryDeleteTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/FSDirectoryDeleteTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.Directory;
@@ -31,7 +32,7 @@ import org.junit.jupiter.api.Test;
public class FSDirectoryDeleteTest extends AbstractIndexCreatorHelper {
protected NexusIndexer nexusIndexer;
- protected File repo = new File(getBasedir(), "src/test/nexus-13");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-13").toFile();
protected IndexingContext context;
diff --git a/indexer-core/src/test/java/org/apache/maven/index/FullIndexNexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/FullIndexNexusIndexerTest.java
index ac845d01..f4c91f58 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/FullIndexNexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/FullIndexNexusIndexerTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -335,7 +336,7 @@ public class FullIndexNexusIndexerTest extends DefaultIndexNexusIndexerTest {
Thread.sleep(1000L);
- File newIndex = new File(getBasedir(), "target/test-new");
+ File newIndex = Path.of(getBasedir(), "target/test-new").toFile();
Directory newIndexDir = FSDirectory.open(newIndex.toPath());
@@ -390,7 +391,7 @@ public class FullIndexNexusIndexerTest extends DefaultIndexNexusIndexerTest {
newContext.close(true);
- assertFalse(new File(newIndex, "timestamp").exists());
+ assertFalse(newIndex.toPath().resolve("timestamp").toFile().exists());
}
@Test
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Mindexer14HitLimitTest.java b/indexer-core/src/test/java/org/apache/maven/index/Mindexer14HitLimitTest.java
index 758e889b..722d0950 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Mindexer14HitLimitTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Mindexer14HitLimitTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import org.apache.lucene.search.Query;
import org.apache.maven.index.expr.SourcedSearchExpression;
@@ -29,7 +30,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Mindexer14HitLimitTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "target/repo/mindexer14");
+ protected File repo = Path.of(getBasedir(), "target/repo/mindexer14").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Mindexer35NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Mindexer35NexusIndexerTest.java
index 58e1b91d..32ae219f 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Mindexer35NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Mindexer35NexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -30,7 +31,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Mindexer35NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/mindexer-35");
+ protected File repo = Path.of(getBasedir(), "src/test/mindexer-35").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus1179NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus1179NexusIndexerTest.java
index 1935b57f..f8948c4f 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus1179NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus1179NexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -30,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class Nexus1179NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/nexus-1179");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-1179").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus13NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus13NexusIndexerTest.java
index 784cd143..4a2a4681 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus13NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus13NexusIndexerTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -47,7 +48,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/** http://issues.sonatype.org/browse/NEXUS-13 */
public class Nexus13NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/nexus-13");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-13").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
@@ -253,9 +254,10 @@ public class Nexus13NexusIndexerTest extends AbstractNexusIndexerTest {
// Using a file
- File artifact = new File(
- repo,
- "cisco/infra/dft/maven-dma-mgmt-plugin/1.0-SNAPSHOT/maven-dma-mgmt-plugin-1.0-20080409.022326-2.jar");
+ File artifact = repo.toPath()
+ .resolve(
+ "cisco/infra/dft/maven-dma-mgmt-plugin/1.0-SNAPSHOT/maven-dma-mgmt-plugin-1.0-20080409.022326-2.jar")
+ .toFile();
ais = nexusIndexer.identify(artifact);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java
index 6d99ffa8..78da705e 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java
@@ -19,7 +19,7 @@
package org.apache.maven.index;
import java.io.File;
-import java.util.Collections;
+import java.util.List;
import org.apache.maven.index.context.IndexingContext;
import org.junit.jupiter.api.AfterEach;
@@ -41,7 +41,7 @@ public class Nexus1911IncrementalMergedCtxTest extends Nexus1911IncrementalTest
indexMergedDir.mkdirs();
context = indexer.addMergedIndexingContext(
- "merged", "merged", member.getRepository(), indexMergedDir, false, Collections.singletonList(member));
+ "merged", "merged", member.getRepository(), indexMergedDir, false, List.of(member));
}
@AfterEach
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalTest.java
index 3564bcbb..010ccebb 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalTest.java
@@ -19,7 +19,9 @@
package org.apache.maven.index;
import java.io.File;
-import java.io.FileInputStream;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
@@ -67,12 +69,12 @@ public class Nexus1911IncrementalTest extends AbstractIndexCreatorHelper {
indexDir = super.getDirectory("index/nexus-1911");
indexPackDir = indexDir; // super.getDirectory( "index/nexus-1911-pack" );
- File reposSrcDir = new File(getBasedir(), "src/test/nexus-1911");
+ File reposSrcDir = Path.of(getBasedir(), "src/test/nexus-1911").toFile();
this.reposTargetDir = super.getDirectory("repos/nexus-1911");
FileUtils.copyDirectoryStructure(reposSrcDir, reposTargetDir);
- File repo = new File(reposTargetDir, "repo");
+ File repo = reposTargetDir.toPath().resolve("repo").toFile();
repo.mkdirs();
reindexedContext =
context = indexer.addIndexingContext("test", "test", repo, indexDir, null, null, DEFAULT_CREATORS);
@@ -133,7 +135,7 @@ public class Nexus1911IncrementalTest extends AbstractIndexCreatorHelper {
}
copyRepoContentsAndReindex(
- new File(getBasedir(), "src/test/nexus-1911/repo-inc-1"), IndexPackingRequest.MAX_CHUNKS);
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-1").toFile(), IndexPackingRequest.MAX_CHUNKS);
Set<String> filenames = getFilenamesFromFiles(indexPackDir.listFiles());
Properties props = getPropertiesFromFiles(indexPackDir.listFiles());
@@ -167,9 +169,9 @@ public class Nexus1911IncrementalTest extends AbstractIndexCreatorHelper {
}
copyRepoContentsAndReindex(
- new File(getBasedir(), "src/test/nexus-1911/repo-inc-1"), IndexPackingRequest.MAX_CHUNKS);
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-1").toFile(), IndexPackingRequest.MAX_CHUNKS);
copyRepoContentsAndReindex(
- new File(getBasedir(), "src/test/nexus-1911/repo-inc-2"), IndexPackingRequest.MAX_CHUNKS);
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-2").toFile(), IndexPackingRequest.MAX_CHUNKS);
Set<String> filenames = getFilenamesFromFiles(indexPackDir.listFiles());
Properties props = getPropertiesFromFiles(indexPackDir.listFiles());
@@ -205,11 +207,11 @@ public class Nexus1911IncrementalTest extends AbstractIndexCreatorHelper {
}
copyRepoContentsAndReindex(
- new File(getBasedir(), "src/test/nexus-1911/repo-inc-1"), IndexPackingRequest.MAX_CHUNKS);
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-1").toFile(), IndexPackingRequest.MAX_CHUNKS);
copyRepoContentsAndReindex(
- new File(getBasedir(), "src/test/nexus-1911/repo-inc-2"), IndexPackingRequest.MAX_CHUNKS);
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-2").toFile(), IndexPackingRequest.MAX_CHUNKS);
copyRepoContentsAndReindex(
- new File(getBasedir(), "src/test/nexus-1911/repo-inc-3"), IndexPackingRequest.MAX_CHUNKS);
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-3").toFile(), IndexPackingRequest.MAX_CHUNKS);
Set<String> filenames = getFilenamesFromFiles(indexPackDir.listFiles());
Properties props = getPropertiesFromFiles(indexPackDir.listFiles());
@@ -245,10 +247,14 @@ public class Nexus1911IncrementalTest extends AbstractIndexCreatorHelper {
context.releaseIndexSearcher(indexSearcher);
}
- copyRepoContentsAndReindex(new File(getBasedir(), "src/test/nexus-1911/repo-inc-1"), 3);
- copyRepoContentsAndReindex(new File(getBasedir(), "src/test/nexus-1911/repo-inc-2"), 3);
- copyRepoContentsAndReindex(new File(getBasedir(), "src/test/nexus-1911/repo-inc-3"), 3);
- copyRepoContentsAndReindex(new File(getBasedir(), "src/test/nexus-1911/repo-inc-4"), 3);
+ copyRepoContentsAndReindex(
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-1").toFile(), 3);
+ copyRepoContentsAndReindex(
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-2").toFile(), 3);
+ copyRepoContentsAndReindex(
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-3").toFile(), 3);
+ copyRepoContentsAndReindex(
+ Path.of(getBasedir(), "src/test/nexus-1911/repo-inc-4").toFile(), 3);
Set<String> filenames = getFilenamesFromFiles(indexPackDir.listFiles());
Properties props = getPropertiesFromFiles(indexPackDir.listFiles());
@@ -276,7 +282,8 @@ public class Nexus1911IncrementalTest extends AbstractIndexCreatorHelper {
}
private void copyRepoContentsAndReindex(File src, int maxIndexChunks) throws Exception {
- File reposTargetDir = new File(getBasedir(), "target/repos/nexus-1911/repo");
+ File reposTargetDir =
+ Path.of(getBasedir(), "target/repos/nexus-1911/repo").toFile();
FileUtils.copyDirectoryStructure(src, reposTargetDir);
@@ -317,7 +324,7 @@ public class Nexus1911IncrementalTest extends AbstractIndexCreatorHelper {
}
}
- try (FileInputStream fis = new FileInputStream(propertyFile)) {
+ try (InputStream fis = Files.newInputStream(propertyFile.toPath())) {
props.load(fis);
}
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus2046NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus2046NexusIndexerTest.java
index 33ef711c..24c42401 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus2046NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus2046NexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -30,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class Nexus2046NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/nexus-2046");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-2046").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus3177HitLimitChecks.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus3177HitLimitChecks.java
index f6c23c7f..74294606 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus3177HitLimitChecks.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus3177HitLimitChecks.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.Set;
import org.apache.lucene.index.Term;
@@ -31,7 +32,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Nexus3177HitLimitChecks extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/repo");
+ protected File repo = Path.of(getBasedir(), "src/test/repo").toFile();
protected Directory secondIndexDir = new ByteBuffersDirectory();
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus3233NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus3233NexusIndexerTest.java
index 4981bc11..65ea6ab4 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus3233NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus3233NexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.Collection;
import org.junit.jupiter.api.Test;
@@ -28,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
/** http://issues.sonatype.org/browse/NEXUS-3233 */
public class Nexus3233NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/nexus-3233");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-3233").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus3293TimestampSnapshotTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus3293TimestampSnapshotTest.java
index 6dbc374c..97b2dbc6 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus3293TimestampSnapshotTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus3293TimestampSnapshotTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.Set;
import org.apache.lucene.index.Term;
@@ -39,10 +40,11 @@ public class Nexus3293TimestampSnapshotTest extends AbstractIndexCreatorHelper {
private NexusIndexer prepare() throws Exception, IOException, UnsupportedExistingLuceneIndexException {
NexusIndexer indexer = lookup(NexusIndexer.class);
- File indexDir = new File(getBasedir(), "target/index/test-" + System.currentTimeMillis());
+ File indexDir = Path.of(getBasedir(), "target/index/test-" + System.currentTimeMillis())
+ .toFile();
FileUtils.deleteDirectory(indexDir);
- File repo = new File(getBasedir(), "src/test/nexus-3293");
+ File repo = Path.of(getBasedir(), "src/test/nexus-3293").toFile();
repo.mkdirs();
context = indexer.addIndexingContext("test", "test", repo, indexDir, null, null, DEFAULT_CREATORS);
@@ -62,9 +64,11 @@ public class Nexus3293TimestampSnapshotTest extends AbstractIndexCreatorHelper {
public void test_nexus_3293_releaseJar() throws Exception {
NexusIndexer indexer = prepare();
- File artifact = new File(getBasedir(), "src/test/nexus-3293/aopalliance/aopalliance/1.0/aopalliance-1.0jar");
+ File artifact = Path.of(getBasedir(), "src/test/nexus-3293/aopalliance/aopalliance/1.0/aopalliance-1.0jar")
+ .toFile();
- File pom = new File(getBasedir(), "src/test/nexus-3293/aopalliance/aopalliance/1.0/aopalliance-1.0.pom");
+ File pom = Path.of(getBasedir(), "src/test/nexus-3293/aopalliance/aopalliance/1.0/aopalliance-1.0.pom")
+ .toFile();
ArtifactInfo artifactInfo = new ArtifactInfo("test", "aopalliance", "aopalliance", "1.0-SNAPSHOT", null, "jar");
@@ -90,13 +94,15 @@ public class Nexus3293TimestampSnapshotTest extends AbstractIndexCreatorHelper {
public void test_nexus_3293_indexTimestampedSnapshotJar() throws Exception {
NexusIndexer indexer = prepare();
- File artifact = new File(
- getBasedir(),
- "src/test/nexus-3293/aopalliance/aopalliance/1.0-SNAPSHOT/aopalliance-1.0-20100517.210215-13.jar");
+ File artifact = Path.of(
+ getBasedir(),
+ "src/test/nexus-3293/aopalliance/aopalliance/1.0-SNAPSHOT/aopalliance-1.0-20100517.210215-13.jar")
+ .toFile();
- File pom = new File(
- getBasedir(),
- "src/test/nexus-3293/aopalliance/aopalliance/1.0-SNAPSHOT/aopalliance-1.0-20100517.210215-13.pom");
+ File pom = Path.of(
+ getBasedir(),
+ "src/test/nexus-3293/aopalliance/aopalliance/1.0-SNAPSHOT/aopalliance-1.0-20100517.210215-13.pom")
+ .toFile();
ArtifactContextProducer artifactContextProducer = lookup(ArtifactContextProducer.class);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus3881NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus3881NexusIndexerTest.java
index 0a201201..3e8b5409 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus3881NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus3881NexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
@@ -28,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Nexus3881NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/nexus-3881");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-3881").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java
index 668695a4..ff00772c 100755
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus4674GavPathReindexTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.Collection;
import java.util.Set;
@@ -28,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Nexus4674GavPathReindexTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/repo");
+ protected File repo = Path.of(getBasedir(), "src/test/repo").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
@@ -54,14 +55,16 @@ public class Nexus4674GavPathReindexTest extends AbstractNexusIndexerTest {
File artifact;
// Using a file: this one should be unknown
- artifact = new File(repo, "qdox/qdox/1.5/qdox-1.5.jar");
+ artifact = repo.toPath().resolve("qdox/qdox/1.5/qdox-1.5.jar").toFile();
ais = nexusIndexer.identify(artifact);
assertTrue(ais.isEmpty(), "Should not be able to identify it!");
// Using a file: this one should be known
- artifact = new File(repo, "org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2.jar");
+ artifact = repo.toPath()
+ .resolve("org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2.jar")
+ .toFile();
ais = nexusIndexer.identify(artifact);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus645NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus645NexusIndexerTest.java
index 99514da8..0bd09fbd 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus645NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus645NexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -30,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
/** http://issues.sonatype.org/browse/NEXUS-13 */
public class Nexus645NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/nexus-645");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-645").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus658NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus658NexusIndexerTest.java
index c0750245..163528ee 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus658NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus658NexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -30,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
/** http://issues.sonatype.org/browse/NEXUS-13 */
public class Nexus658NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/nexus-658");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-658").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus687NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus687NexusIndexerTest.java
index 5a1ba989..d0c0d4f9 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus687NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus687NexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -32,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* @author Juven Xu http://issues.sonatype.org/browse/NEXUS-687
*/
public class Nexus687NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/nexus-687");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-687").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus737NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus737NexusIndexerTest.java
index be5b2679..c98f912d 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/Nexus737NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus737NexusIndexerTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
@@ -30,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
/** http://issues.sonatype.org/browse/NEXUS-737 */
public class Nexus737NexusIndexerTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/nexus-658");
+ protected File repo = Path.of(getBasedir(), "src/test/nexus-658").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java
index 075d39e3..753240eb 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java
@@ -20,15 +20,14 @@ package org.apache.maven.index;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -73,7 +72,7 @@ public class NexusIndexerTest extends AbstractIndexCreatorHelper {
File indexDir = super.getDirectory("index/test");
super.deleteDirectory(indexDir);
- File repo = new File(getBasedir(), "src/test/repo");
+ File repo = Path.of(getBasedir(), "src/test/repo").toFile();
context = indexer.addIndexingContext("test", "test", repo, indexDir, null, null, DEFAULT_CREATORS);
indexer.scan(context);
@@ -240,7 +239,7 @@ public class NexusIndexerTest extends AbstractIndexCreatorHelper {
.build();
// invoking the old method (was present since day 1), that will return the match only and if only there is 1 hit
- Collection<ArtifactInfo> ais = indexer.identify(bq, Collections.singletonList(context));
+ Collection<ArtifactInfo> ais = indexer.identify(bq, List.of(context));
assertEquals(1, ais.size());
@@ -275,7 +274,7 @@ public class NexusIndexerTest extends AbstractIndexCreatorHelper {
context.getRepository(),
indexMergedDir,
true,
- new StaticContextMemberProvider(Collections.singletonList(context)));
+ new StaticContextMemberProvider(List.of(context)));
performQueryCreatorNGSearch(indexer, mergedContext);
}
@@ -332,7 +331,7 @@ public class NexusIndexerTest extends AbstractIndexCreatorHelper {
StringWriter ressw = new StringWriter();
PrintWriter respw = new PrintWriter(ressw);
- BufferedReader reader = new BufferedReader(new FileReader(expectedResults, StandardCharsets.UTF_8));
+ BufferedReader reader = Files.newBufferedReader(expectedResults.toPath(), StandardCharsets.UTF_8);
String currentline;
while ((currentline = reader.readLine()) != null) {
@@ -477,7 +476,8 @@ public class NexusIndexerTest extends AbstractIndexCreatorHelper {
// Using a file
- File artifact = new File(getBasedir(), "src/test/repo/qdox/qdox/1.5/qdox-1.5.jar");
+ File artifact = Path.of(getBasedir(), "src/test/repo/qdox/qdox/1.5/qdox-1.5.jar")
+ .toFile();
ais = nexus.identify(artifact);
@@ -524,9 +524,9 @@ public class NexusIndexerTest extends AbstractIndexCreatorHelper {
// String fname = indexingContext.getRepository().getAbsolutePath() + "/" + ai.groupId.replace( '.', '/' ) + "/"
// + ai.artifactId + "/" + ai.version + "/" + ai.artifactId + "-" + ai.version;
- // File pom = new File( fname + ".pom" );
+ // File pom = Path.of(fname + ".pom").toFile();
- // File artifact = new File( fname + ".jar" );
+ // File artifact = Path.of(fname + ".jar").toFile();
indexer.addArtifactToIndex(new ArtifactContext(null, null, null, ai, null), indexingContext);
@@ -596,7 +596,7 @@ public class NexusIndexerTest extends AbstractIndexCreatorHelper {
File indexDir = super.getDirectory("index/test");
super.deleteDirectory(indexDir);
- File repo = new File(getBasedir(), "src/test/repo");
+ File repo = Path.of(getBasedir(), "src/test/repo").toFile();
context = indexer.addIndexingContext("test", "test", repo, indexDir, null, null, DEFAULT_CREATORS);
indexer.scan(context);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/SearchWithAnEmptyIndexTest.java b/indexer-core/src/test/java/org/apache/maven/index/SearchWithAnEmptyIndexTest.java
index bc1adcdf..a94c4d57 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/SearchWithAnEmptyIndexTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/SearchWithAnEmptyIndexTest.java
@@ -21,6 +21,7 @@ package org.apache.maven.index;
import javax.inject.Inject;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -72,7 +73,7 @@ public class SearchWithAnEmptyIndexTest extends AbstractTestSupport {
String repoPath = "target/test/empty-repo-for-searchtest";
- File emptyRepo = new File(getBasedir(), repoPath);
+ File emptyRepo = Path.of(getBasedir(), repoPath).toFile();
if (emptyRepo.exists()) {
FileUtils.deleteDirectory(emptyRepo);
@@ -153,7 +154,7 @@ public class SearchWithAnEmptyIndexTest extends AbstractTestSupport {
String repoPathIndex = "target/test/repo-for-searchdupe";
- File emptyRepo = new File(getBasedir(), repoPathIndex);
+ File emptyRepo = Path.of(getBasedir(), repoPathIndex).toFile();
if (emptyRepo.exists()) {
FileUtils.deleteDirectory(emptyRepo);
@@ -200,9 +201,9 @@ public class SearchWithAnEmptyIndexTest extends AbstractTestSupport {
private void createIndex(String filePath, String repoIndex, String contextId) throws Exception {
- File repo = new File(getBasedir(), filePath);
+ File repo = Path.of(getBasedir(), filePath).toFile();
- File repoIndexDir = new File(getBasedir(), repoIndex + "/.index");
+ File repoIndexDir = Path.of(getBasedir(), repoIndex + "/.index").toFile();
if (repoIndexDir.exists()) {
FileUtils.deleteDirectory(repoIndexDir);
@@ -225,10 +226,11 @@ public class SearchWithAnEmptyIndexTest extends AbstractTestSupport {
indexingContext.optimize();
- File managedRepository = new File(repoIndex);
+ File managedRepository = Path.of(repoIndex).toFile();
final IndexSearcher indexSearcher = indexingContext.acquireIndexSearcher();
try {
- final File indexLocation = new File(managedRepository, ".index");
+ final File indexLocation =
+ managedRepository.toPath().resolve(".index").toFile();
IndexPackingRequest request =
new IndexPackingRequest(indexingContext, indexSearcher.getIndexReader(), indexLocation);
indexPacker.packIndex(request);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/SubPathReindexTest.java b/indexer-core/src/test/java/org/apache/maven/index/SubPathReindexTest.java
index ac586c30..9282a123 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/SubPathReindexTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/SubPathReindexTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index;
import java.io.File;
+import java.nio.file.Path;
import java.util.Collection;
import java.util.Set;
@@ -28,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class SubPathReindexTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/repo");
+ protected File repo = Path.of(getBasedir(), "src/test/repo").toFile();
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
@@ -79,14 +80,16 @@ public class SubPathReindexTest extends AbstractNexusIndexerTest {
File artifact;
// Using a file: this one should be unknown
- artifact = new File(repo, "qdox/qdox/1.5/qdox-1.5.jar");
+ artifact = repo.toPath().resolve("qdox/qdox/1.5/qdox-1.5.jar").toFile();
ais = nexusIndexer.identify(artifact);
assertTrue(ais.isEmpty(), "Should not be able to identify it!");
// Using a file: this one should be known
- artifact = new File(repo, "org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2.jar");
+ artifact = repo.toPath()
+ .resolve("org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2.jar")
+ .toFile();
ais = nexusIndexer.identify(artifact);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/UniqueArtifactFilterTest.java b/indexer-core/src/test/java/org/apache/maven/index/UniqueArtifactFilterTest.java
index a0e34f78..52f84dc7 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/UniqueArtifactFilterTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/UniqueArtifactFilterTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import org.apache.lucene.search.Query;
import org.apache.maven.index.context.IndexingContext;
@@ -92,10 +93,11 @@ public class UniqueArtifactFilterTest extends AbstractIndexCreatorHelper {
NexusIndexer indexer = lookup(NexusIndexer.class);
// Directory indexDir = new RAMDirectory();
- File indexDir = new File(getBasedir(), "target/index/test-" + System.currentTimeMillis());
+ File indexDir = Path.of(getBasedir(), "target/index/test-" + System.currentTimeMillis())
+ .toFile();
FileUtils.deleteDirectory(indexDir);
- File repo = new File(getBasedir(), "src/test/repo");
+ File repo = Path.of(getBasedir(), "src/test/repo").toFile();
context = indexer.addIndexingContext("test", "test", repo, indexDir, null, null, DEFAULT_CREATORS);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/creator/JarFileContentsIndexCreatorTest.java b/indexer-core/src/test/java/org/apache/maven/index/creator/JarFileContentsIndexCreatorTest.java
index f15f758c..939abc17 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/creator/JarFileContentsIndexCreatorTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/creator/JarFileContentsIndexCreatorTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index.creator;
import java.io.File;
+import java.nio.file.Path;
import org.apache.maven.index.AbstractTestSupport;
import org.apache.maven.index.ArtifactContext;
@@ -48,9 +49,11 @@ public class JarFileContentsIndexCreatorTest extends AbstractTestSupport {
@Test
public void test_nexus_2318_indexJarWithClasses() throws Exception {
- File artifact = new File(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.jar");
+ File artifact = Path.of(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.jar")
+ .toFile();
- File pom = new File(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom");
+ File pom = Path.of(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom")
+ .toFile();
ArtifactInfo artifactInfo = new ArtifactInfo("test", "aopalliance", "aopalliance", "1.0", null, "jar");
@@ -63,9 +66,11 @@ public class JarFileContentsIndexCreatorTest extends AbstractTestSupport {
@Test
public void test_nexus_2318_indexZipWithClasses() throws Exception {
- File artifact = new File(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.zip");
+ File artifact = Path.of(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.zip")
+ .toFile();
- File pom = new File(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom");
+ File pom = Path.of(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom")
+ .toFile();
ArtifactInfo artifactInfo = new ArtifactInfo("test", "aopalliance", "aopalliance", "1.0", null, "zip");
@@ -108,10 +113,12 @@ public class JarFileContentsIndexCreatorTest extends AbstractTestSupport {
@Test
public void test_nexus_2318_indexJarWithSources() throws Exception {
- File artifact =
- new File(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar");
+ File artifact = Path.of(
+ getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar")
+ .toFile();
- File pom = new File(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom");
+ File pom = Path.of(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom")
+ .toFile();
ArtifactInfo artifactInfo = new ArtifactInfo("test", "aopalliance", "aopalliance", "1.0", null, "jar");
@@ -124,10 +131,12 @@ public class JarFileContentsIndexCreatorTest extends AbstractTestSupport {
@Test
public void test_nexus_2318_indexZipWithSources() throws Exception {
- File artifact =
- new File(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.zip");
+ File artifact = Path.of(
+ getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.zip")
+ .toFile();
- File pom = new File(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom");
+ File pom = Path.of(getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom")
+ .toFile();
ArtifactInfo artifactInfo = new ArtifactInfo("test", "aopalliance", "aopalliance", "1.0", null, "zip");
@@ -140,13 +149,15 @@ public class JarFileContentsIndexCreatorTest extends AbstractTestSupport {
@Test
public void testMindexer35ScanWar() throws Exception {
- File artifact = new File(
- getBasedir(),
- "src/test/mindexer-35/org/apache/maven/indexer/test/sample-war/1.0-SNAPSHOT/sample-war-1.0-SNAPSHOT.war");
-
- File pom = new File(
- getBasedir(),
- "src/test/mindexer-35/org/apache/maven/indexer/test/sample-war/1.0-SNAPSHOT/sample-war-1.0-SNAPSHOT.pom");
+ File artifact = Path.of(
+ getBasedir(),
+ "src/test/mindexer-35/org/apache/maven/indexer/test/sample-war/1.0-SNAPSHOT/sample-war-1.0-SNAPSHOT.war")
+ .toFile();
+
+ File pom = Path.of(
+ getBasedir(),
+ "src/test/mindexer-35/org/apache/maven/indexer/test/sample-war/1.0-SNAPSHOT/sample-war-1.0-SNAPSHOT.pom")
+ .toFile();
ArtifactInfo artifactInfo =
new ArtifactInfo("test", "org.apache.maven.indexer.test", "sample-war", "1.0-SNAPSHOT", null, "war");
diff --git a/indexer-core/src/test/java/org/apache/maven/index/creator/MavenPluginArtifactInfoIndexCreatorTest.java b/indexer-core/src/test/java/org/apache/maven/index/creator/MavenPluginArtifactInfoIndexCreatorTest.java
index acb28838..885561d2 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/creator/MavenPluginArtifactInfoIndexCreatorTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/creator/MavenPluginArtifactInfoIndexCreatorTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index.creator;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
@@ -47,13 +48,15 @@ public class MavenPluginArtifactInfoIndexCreatorTest extends AbstractTestSupport
@Test
public void testMavenPluginInfo() throws Exception {
- File artifact = new File(
- getBasedir(),
- "src/test/repo-creator/org/apache/maven/plugins/maven-dependency-plugin/2.0/maven-dependency-plugin-2.0.jar");
+ File artifact = Path.of(
+ getBasedir(),
+ "src/test/repo-creator/org/apache/maven/plugins/maven-dependency-plugin/2.0/maven-dependency-plugin-2.0.jar")
+ .toFile();
- File pom = new File(
- getBasedir(),
- "src/test/repo-creator/org/apache/maven/plugins/maven-dependency-plugin/2.0/maven-dependency-plugin-2.0.pom");
+ File pom = Path.of(
+ getBasedir(),
+ "src/test/repo-creator/org/apache/maven/plugins/maven-dependency-plugin/2.0/maven-dependency-plugin-2.0.pom")
+ .toFile();
ArtifactInfo artifactInfo =
new ArtifactInfo("test", "org.apache.maven.plugins", "maven-dependency-plugin", "2.0", null, "jar");
diff --git a/indexer-core/src/test/java/org/apache/maven/index/creator/OsgiArtifactIndexCreatorTest.java b/indexer-core/src/test/java/org/apache/maven/index/creator/OsgiArtifactIndexCreatorTest.java
index 61d0f5b5..39d5ff46 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/creator/OsgiArtifactIndexCreatorTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/creator/OsgiArtifactIndexCreatorTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index.creator;
import java.io.File;
+import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
@@ -71,13 +72,15 @@ public class OsgiArtifactIndexCreatorTest extends AbstractTestSupport {
@Test
public void testPopulateArtifactInfo() throws Exception {
- File artifact = new File(
- getBasedir(),
- "src/test/repo-with-osgi/org/apache/karaf/features/org.apache.karaf.features.command/2.2.2/org.apache.karaf.features.command-2.2.2.jar");
+ File artifact = Path.of(
+ getBasedir(),
+ "src/test/repo-with-osgi/org/apache/karaf/features/org.apache.karaf.features.command/2.2.2/org.apache.karaf.features.command-2.2.2.jar")
+ .toFile();
- File pom = new File(
- getBasedir(),
- "src/test/repo-with-osgi/org/apache/karaf/features/org.apache.karaf.features.command/2.2.2/org.apache.karaf.features.command-2.2.2.pom");
+ File pom = Path.of(
+ getBasedir(),
+ "src/test/repo-with-osgi/org/apache/karaf/features/org.apache.karaf.features.command/2.2.2/org.apache.karaf.features.command-2.2.2.pom")
+ .toFile();
ArtifactInfo artifactInfo = new ArtifactInfo(
"test", "org.apache.karaf.features", "org.apache.karaf.features.command", "2.2.2", null, "jar");
@@ -117,11 +120,12 @@ public class OsgiArtifactIndexCreatorTest extends AbstractTestSupport {
@Test
public void testPopulateFragmentHost() throws Exception {
- File artifact =
- new File(getBasedir(), "src/test/repo-with-osgi/org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar");
+ File artifact = Path.of(
+ getBasedir(), "src/test/repo-with-osgi/org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar")
+ .toFile();
- File pom =
- new File(getBasedir(), "src/test/repo-with-osgi/org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.pom");
+ File pom = Path.of(getBasedir(), "src/test/repo-with-osgi/org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.pom")
+ .toFile();
ArtifactInfo artifactInfo = new ArtifactInfo("test", "org.slf4j", "slf4j-simple", "1.7.7", null, "jar");
ArtifactContext artifactContext = new ArtifactContext(pom, artifact, null, artifactInfo, null);
@@ -131,13 +135,15 @@ public class OsgiArtifactIndexCreatorTest extends AbstractTestSupport {
@Test
public void testPopulateCapabilityAndSha256() throws Exception {
- File artifact = new File(
- getBasedir(),
- "src/test/repo-with-osgi/org/apache/karaf/features/org.apache.karaf.features.core/4.1.0/org.apache.karaf.features.core-4.1.0.jar");
+ File artifact = Path.of(
+ getBasedir(),
+ "src/test/repo-with-osgi/org/apache/karaf/features/org.apache.karaf.features.core/4.1.0/org.apache.karaf.features.core-4.1.0.jar")
+ .toFile();
- File pom = new File(
- getBasedir(),
- "src/test/repo-with-osgi/org/apache/karaf/features/oorg.apache.karaf.features.core/4.1.0/org.apache.karaf.features.core-4.1.0.pom");
+ File pom = Path.of(
+ getBasedir(),
+ "src/test/repo-with-osgi/org/apache/karaf/features/oorg.apache.karaf.features.core/4.1.0/org.apache.karaf.features.core-4.1.0.pom")
+ .toFile();
ArtifactInfo artifactInfo = new ArtifactInfo(
"test", "org.apache.karaf.features", "org.apache.karaf.features.core", "4.1.0", null, "jar");
@@ -162,9 +168,10 @@ public class OsgiArtifactIndexCreatorTest extends AbstractTestSupport {
private void indexOSGIRepo() throws Exception {
- File repo = new File(getBasedir(), "src/test/repo-with-osgi");
+ File repo = Path.of(getBasedir(), "src/test/repo-with-osgi").toFile();
- File repoIndexDir = new File(getBasedir(), "target/test/repo-with-osgi/.index/");
+ File repoIndexDir =
+ Path.of(getBasedir(), "target/test/repo-with-osgi/.index/").toFile();
if (repoIndexDir.exists()) {
FileUtils.deleteDirectory(repoIndexDir);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/incremental/DefaultIncrementalHandlerTest.java b/indexer-core/src/test/java/org/apache/maven/index/incremental/DefaultIncrementalHandlerTest.java
index 5071734a..af347f96 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/incremental/DefaultIncrementalHandlerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/incremental/DefaultIncrementalHandlerTest.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Path;
import java.util.List;
import java.util.Properties;
@@ -59,8 +60,8 @@ public class DefaultIncrementalHandlerTest extends AbstractIndexCreatorHelper {
indexer = lookup(NexusIndexer.class);
handler = lookup(IncrementalHandler.class);
- indexDir = new File(getBasedir(), "target/index/nexus-incremental-test");
- repoDir = new File(getBasedir(), "target/repos/nexus-incremental-test");
+ indexDir = Path.of(getBasedir(), "target/index/nexus-incremental-test").toFile();
+ repoDir = Path.of(getBasedir(), "target/repos/nexus-incremental-test").toFile();
FileUtils.deleteDirectory(indexDir);
FileUtils.deleteDirectory(repoDir);
@@ -107,7 +108,9 @@ public class DefaultIncrementalHandlerTest extends AbstractIndexCreatorHelper {
properties.setProperty(IndexingContext.INDEX_TIMESTAMP, "19991112182432.432 -0600");
- FileUtils.copyDirectoryStructure(new File(getBasedir(), "src/test/repo/ch"), new File(repoDir, "ch"));
+ FileUtils.copyDirectoryStructure(
+ Path.of(getBasedir(), "src/test/repo/ch").toFile(),
+ repoDir.toPath().resolve("ch").toFile());
indexer.scan(context);
diff --git a/indexer-core/src/test/java/org/apache/maven/index/locator/ArtifactLocatorTest.java b/indexer-core/src/test/java/org/apache/maven/index/locator/ArtifactLocatorTest.java
index d55ad5cc..342e922f 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/locator/ArtifactLocatorTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/locator/ArtifactLocatorTest.java
@@ -39,7 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ArtifactLocatorTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/repo");
+ protected File repo = Path.of(getBasedir(), "src/test/repo").toFile();
private ArtifactContextProducer artifactContextProducer;
diff --git a/indexer-core/src/test/java/org/apache/maven/index/packer/NEXUS4149TransferFormatTest.java b/indexer-core/src/test/java/org/apache/maven/index/packer/NEXUS4149TransferFormatTest.java
index dfabd5f1..597f391f 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/packer/NEXUS4149TransferFormatTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/packer/NEXUS4149TransferFormatTest.java
@@ -20,9 +20,10 @@ package org.apache.maven.index.packer;
import java.io.BufferedInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
@@ -43,9 +44,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class NEXUS4149TransferFormatTest extends AbstractNexusIndexerTest {
- protected File reposBase = new File(getBasedir(), "src/test/nexus-4149");
+ protected File reposBase = Path.of(getBasedir(), "src/test/nexus-4149").toFile();
- protected File idxsBase = new File(getBasedir(), "target/index/nexus-4149");
+ protected File idxsBase = Path.of(getBasedir(), "target/index/nexus-4149").toFile();
@BeforeEach
@Override
@@ -56,26 +57,50 @@ public class NEXUS4149TransferFormatTest extends AbstractNexusIndexerTest {
@Override
protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
IndexingContext ctx1 = nexusIndexer.addIndexingContext(
- "repo1", "repo1", new File(reposBase, "repo1"), new File(idxsBase, "repo1"), null, null, MIN_CREATORS);
+ "repo1",
+ "repo1",
+ reposBase.toPath().resolve("repo1").toFile(),
+ idxsBase.toPath().resolve("repo1").toFile(),
+ null,
+ null,
+ MIN_CREATORS);
nexusIndexer.scan(ctx1);
IndexingContext ctx2 = nexusIndexer.addIndexingContext(
- "repo2", "repo2", new File(reposBase, "repo2"), new File(idxsBase, "repo2"), null, null, MIN_CREATORS);
+ "repo2",
+ "repo2",
+ reposBase.toPath().resolve("repo2").toFile(),
+ idxsBase.toPath().resolve("repo2").toFile(),
+ null,
+ null,
+ MIN_CREATORS);
nexusIndexer.scan(ctx2);
IndexingContext ctx3 = nexusIndexer.addIndexingContext(
- "repo3", "repo3", new File(reposBase, "repo3"), new File(idxsBase, "repo3"), null, null, MIN_CREATORS);
+ "repo3",
+ "repo3",
+ reposBase.toPath().resolve("repo3").toFile(),
+ idxsBase.toPath().resolve("repo3").toFile(),
+ null,
+ null,
+ MIN_CREATORS);
nexusIndexer.scan(ctx3);
IndexingContext ctx4 = nexusIndexer.addIndexingContext(
- "repo4", "repo4", new File(reposBase, "repo4"), new File(idxsBase, "repo4"), null, null, MIN_CREATORS);
+ "repo4",
+ "repo4",
+ reposBase.toPath().resolve("repo4").toFile(),
+ idxsBase.toPath().resolve("repo4").toFile(),
+ null,
+ null,
+ MIN_CREATORS);
nexusIndexer.scan(ctx4);
context = nexusIndexer.addMergedIndexingContext(
"ctx",
"ctx",
- new File(reposBase, "merged"),
- new File(idxsBase, "merged"),
+ reposBase.toPath().resolve("merged").toFile(),
+ idxsBase.toPath().resolve("merged").toFile(),
false,
Arrays.asList(ctx1, ctx2, ctx3, ctx4));
@@ -118,7 +143,7 @@ public class NEXUS4149TransferFormatTest extends AbstractNexusIndexerTest {
@Test
public void testTransportFile() throws Exception {
- File packTargetDir = new File(getBasedir(), "target/nexus-4149/packed");
+ File packTargetDir = Path.of(getBasedir(), "target/nexus-4149/packed").toFile();
IndexPacker packer = lookup(IndexPacker.class);
@@ -135,8 +160,11 @@ public class NEXUS4149TransferFormatTest extends AbstractNexusIndexerTest {
}
// read it up and verify, but stay "low level", directly consume the GZ file and count
- InputStream fis = new BufferedInputStream(
- new FileInputStream(new File(packTargetDir, "nexus-maven-repository-index.gz")));
+ InputStream fis = new BufferedInputStream(Files.newInputStream((packTargetDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.gz")
+ .toFile())
+ .toPath()));
IndexDataReader reader = new IndexDataReader(fis);
try {
// read header and neglect it
diff --git a/indexer-core/src/test/java/org/apache/maven/index/treeview/IndexTreeViewTest.java b/indexer-core/src/test/java/org/apache/maven/index/treeview/IndexTreeViewTest.java
index 54bc6d45..7b347067 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/treeview/IndexTreeViewTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/treeview/IndexTreeViewTest.java
@@ -19,6 +19,7 @@
package org.apache.maven.index.treeview;
import java.io.File;
+import java.nio.file.Path;
import org.apache.maven.index.AbstractNexusIndexerTest;
import org.apache.maven.index.NexusIndexer;
@@ -28,7 +29,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class IndexTreeViewTest extends AbstractNexusIndexerTest {
- protected File repo = new File(getBasedir(), "src/test/repo");
+ protected File repo = Path.of(getBasedir(), "src/test/repo").toFile();
protected IndexTreeView indexTreeView;
diff --git a/indexer-core/src/test/java/org/apache/maven/index/updater/AbstractIndexUpdaterTest.java b/indexer-core/src/test/java/org/apache/maven/index/updater/AbstractIndexUpdaterTest.java
index 03c1f116..ac46da1a 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/updater/AbstractIndexUpdaterTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/updater/AbstractIndexUpdaterTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index.updater;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.ArrayList;
import org.apache.lucene.search.IndexSearcher;
@@ -66,10 +67,10 @@ public abstract class AbstractIndexUpdaterTest extends AbstractIndexCreatorHelpe
public void setUp() throws Exception {
super.setUp();
- testBasedir = new File(getBasedir(), "/target/indexUpdater");
+ testBasedir = Path.of(getBasedir(), "/target/indexUpdater").toFile();
testBasedir.mkdirs();
- repoDir = new File(getBasedir(), "/target/indexUpdaterRepoDir");
+ repoDir = Path.of(getBasedir(), "/target/indexUpdaterRepoDir").toFile();
repoDir.mkdirs();
indexDir = super.getDirectory("indexerUpdater");
@@ -103,8 +104,8 @@ public abstract class AbstractIndexUpdaterTest extends AbstractIndexCreatorHelpe
protected ArtifactContext createArtifactContext(
String repositoryId, String groupId, String artifactId, String version, String classifier) {
String path = createPath(groupId, artifactId, version, classifier);
- File pomFile = new File(path + ".pom");
- File artifact = new File(path + ".jar");
+ File pomFile = Path.of(path + ".pom").toFile();
+ File artifact = Path.of(path + ".jar").toFile();
File metadata = null;
ArtifactInfo artifactInfo = new ArtifactInfo(repositoryId, groupId, artifactId, version, classifier, "jar");
Gav gav = new Gav(
diff --git a/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterTest.java b/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterTest.java
index 69e299a7..642a1bc7 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterTest.java
@@ -21,10 +21,11 @@ package org.apache.maven.index.updater;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
@@ -259,14 +260,14 @@ public class DefaultIndexUpdaterTest extends AbstractIndexUpdaterTest {
@Test
public void testMergeSearch() throws Exception {
- File repo1 = new File(getBasedir(), "src/test/nexus-658");
+ File repo1 = Path.of(getBasedir(), "src/test/nexus-658").toFile();
Directory indexDir1 = new ByteBuffersDirectory();
IndexingContext context1 =
indexer.addIndexingContext("nexus-658", "nexus-658", repo1, indexDir1, null, null, DEFAULT_CREATORS);
indexer.scan(context1);
- File repo2 = new File(getBasedir(), "src/test/nexus-13");
+ File repo2 = Path.of(getBasedir(), "src/test/nexus-13").toFile();
Directory indexDir2 = new ByteBuffersDirectory();
IndexingContext context2 =
@@ -643,7 +644,7 @@ public class DefaultIndexUpdaterTest extends AbstractIndexUpdaterTest {
protected InputStream newInputStream(String path) throws IOException {
File file = getTestFile("src/test/resources/" + path);
if (file.isFile()) {
- return new FileInputStream(file);
+ return Files.newInputStream(file.toPath());
}
return null;
}
@@ -672,8 +673,8 @@ public class DefaultIndexUpdaterTest extends AbstractIndexUpdaterTest {
/** Writes the local updater properties into basedir and returns it as the index directory. */
private static File indexDirectoryWithProperties(Properties properties, File basedir) throws IOException {
basedir.mkdirs();
- try (FileOutputStream fos =
- new FileOutputStream(new File(basedir, IndexingContext.INDEX_UPDATER_PROPERTIES_FILE))) {
+ try (OutputStream fos =
+ Files.newOutputStream(Path.of(basedir.getPath(), IndexingContext.INDEX_UPDATER_PROPERTIES_FILE))) {
properties.store(fos, "");
}
return basedir;
diff --git a/indexer-core/src/test/java/org/apache/maven/index/updater/DownloadRemoteIndexerManagerTest.java b/indexer-core/src/test/java/org/apache/maven/index/updater/DownloadRemoteIndexerManagerTest.java
index d3de2bbf..36d8f51c 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/updater/DownloadRemoteIndexerManagerTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/updater/DownloadRemoteIndexerManagerTest.java
@@ -23,6 +23,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
@@ -50,7 +51,7 @@ public class DownloadRemoteIndexerManagerTest extends AbstractIndexUpdaterTest {
public void setUp() throws Exception {
super.setUp();
- fakeCentral = new File(getBasedir(), "target/repos/fake-central");
+ fakeCentral = Path.of(getBasedir(), "target/repos/fake-central").toFile();
fakeCentral.mkdirs();
// create proxy server
@@ -86,9 +87,11 @@ public class DownloadRemoteIndexerManagerTest extends AbstractIndexUpdaterTest {
public void testRepoReindex() throws Exception {
IndexUpdateRequest iur;
- File index1 = new File(getBasedir(), "src/test/resources/repo-index/index");
- File index2 = new File(getBasedir(), "src/test/resources/repo-index/index2");
- File centralIndex = new File(fakeCentral, ".index");
+ File index1 =
+ Path.of(getBasedir(), "src/test/resources/repo-index/index").toFile();
+ File index2 =
+ Path.of(getBasedir(), "src/test/resources/repo-index/index2").toFile();
+ File centralIndex = fakeCentral.toPath().resolve(".index").toFile();
// copy index 02
overwriteIndex(index2, centralIndex);
@@ -124,8 +127,12 @@ public class DownloadRemoteIndexerManagerTest extends AbstractIndexUpdaterTest {
}
private void overwriteIndex(File source, File destination) throws Exception {
- File indexFile = new File(destination, "nexus-maven-repository-index.gz");
- File indexProperties = new File(destination, "nexus-maven-repository-index.properties");
+ File indexFile =
+ destination.toPath().resolve("nexus-maven-repository-index.gz").toFile();
+ File indexProperties = destination
+ .toPath()
+ .resolve("nexus-maven-repository-index.properties")
+ .toFile();
long lastMod = -1;
if (destination.exists()) {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/updater/LocalIndexCacheTest.java b/indexer-core/src/test/java/org/apache/maven/index/updater/LocalIndexCacheTest.java
index b78542b3..98f53eaa 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/updater/LocalIndexCacheTest.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/updater/LocalIndexCacheTest.java
@@ -19,9 +19,11 @@
package org.apache.maven.index.updater;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
@@ -56,15 +58,15 @@ public class LocalIndexCacheTest extends AbstractIndexUpdaterTest {
public void setUp() throws Exception {
super.setUp();
- remoteRepo = new File("target/localcache/remoterepo").getCanonicalFile();
+ remoteRepo = Path.of("target/localcache/remoterepo").toFile().getCanonicalFile();
FileUtils.deleteDirectory(remoteRepo);
remoteRepo.mkdirs();
- localCacheDir = new File("target/localcache/cache").getCanonicalFile();
+ localCacheDir = Path.of("target/localcache/cache").toFile().getCanonicalFile();
FileUtils.deleteDirectory(localCacheDir);
localCacheDir.mkdirs();
- indexDir = new File("target/localcache/index").getCanonicalFile();
+ indexDir = Path.of("target/localcache/index").toFile().getCanonicalFile();
FileUtils.deleteDirectory(indexDir);
indexDir.mkdirs();
}
@@ -113,8 +115,16 @@ public class LocalIndexCacheTest extends AbstractIndexUpdaterTest {
updateRequest.setLocalIndexCacheDir(localCacheDir);
updater.fetchAndUpdateIndex(updateRequest);
assertEquals(2, fetcher.getRetrievedResources().size());
- assertTrue(new File(localCacheDir, "nexus-maven-repository-index.gz").exists());
- assertTrue(new File(localCacheDir, "nexus-maven-repository-index.properties").exists());
+ assertTrue(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.gz")
+ .toFile()
+ .exists());
+ assertTrue(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.properties")
+ .toFile()
+ .exists());
assertGroupCount(1, "commons-lang", testContext);
// update the same index (expected: no index download)
@@ -179,8 +189,16 @@ public class LocalIndexCacheTest extends AbstractIndexUpdaterTest {
updateRequest.setLocalIndexCacheDir(localCacheDir);
updater.fetchAndUpdateIndex(updateRequest);
assertEquals(2, fetcher.getRetrievedResources().size());
- assertTrue(new File(localCacheDir, "nexus-maven-repository-index.gz").exists());
- assertTrue(new File(localCacheDir, "nexus-maven-repository-index.properties").exists());
+ assertTrue(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.gz")
+ .toFile()
+ .exists());
+ assertTrue(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.properties")
+ .toFile()
+ .exists());
assertGroupCount(2, "commons-lang", testContext);
}
@@ -207,7 +225,11 @@ public class LocalIndexCacheTest extends AbstractIndexUpdaterTest {
updater.fetchAndUpdateIndex(updateRequest);
// corrupt local cache
- try (FileOutputStream fos = new FileOutputStream(new File(localCacheDir, "nexus-maven-repository-index.gz"))) {
+ try (OutputStream fos = Files.newOutputStream((localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.gz")
+ .toFile())
+ .toPath())) {
IOUtil.copy("corrupted", fos);
}
@@ -236,8 +258,16 @@ public class LocalIndexCacheTest extends AbstractIndexUpdaterTest {
updateRequest.setLocalIndexCacheDir(localCacheDir);
updateRequest.setForceFullUpdate(true);
updater.fetchAndUpdateIndex(updateRequest);
- assertTrue(new File(localCacheDir, "nexus-maven-repository-index.gz").exists());
- assertTrue(new File(localCacheDir, "nexus-maven-repository-index.properties").exists());
+ assertTrue(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.gz")
+ .toFile()
+ .exists());
+ assertTrue(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.properties")
+ .toFile()
+ .exists());
}
@Test
@@ -274,8 +304,16 @@ public class LocalIndexCacheTest extends AbstractIndexUpdaterTest {
updateRequest = new IndexUpdateRequest(getNewTempContext(), fetcher);
updateRequest.setLocalIndexCacheDir(localCacheDir);
updater.fetchAndUpdateIndex(updateRequest);
- assertTrue(new File(localCacheDir, "nexus-maven-repository-index.gz").exists());
- assertTrue(new File(localCacheDir, "nexus-maven-repository-index.properties").exists());
+ assertTrue(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.gz")
+ .toFile()
+ .exists());
+ assertTrue(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.properties")
+ .toFile()
+ .exists());
}
@Test
@@ -306,22 +344,27 @@ public class LocalIndexCacheTest extends AbstractIndexUpdaterTest {
updater.fetchAndUpdateIndex(updateRequest);
// sanity check
- assertTrue(new File(localCacheDir, "nexus-maven-repository-index.1.gz").canRead());
+ assertTrue(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.1.gz")
+ .toFile()
+ .canRead());
// .lock files are expected to be preserved
- File lockFile = new File(localCacheDir, Locker.LOCK_FILE);
- try (FileOutputStream lockFileOutput = new FileOutputStream(lockFile)) {
+ File lockFile = Path.of(localCacheDir.getPath(), Locker.LOCK_FILE).toFile();
+ try (OutputStream lockFileOutput = Files.newOutputStream(lockFile.toPath())) {
IOUtil.copy("", lockFileOutput);
}
assertTrue(lockFile.canRead());
// all unknown files and directories are expected to be removed
- File unknownFile = new File(localCacheDir, "unknownFile");
- try (FileOutputStream fileOutputStream = new FileOutputStream(unknownFile)) {
+ File unknownFile = localCacheDir.toPath().resolve("unknownFile").toFile();
+ try (OutputStream fileOutputStream = Files.newOutputStream(unknownFile.toPath())) {
IOUtil.copy("", fileOutputStream);
}
- File unknownDirectory = new File(localCacheDir, "unknownDirectory");
+ File unknownDirectory =
+ localCacheDir.toPath().resolve("unknownDirectory").toFile();
unknownDirectory.mkdirs();
assertTrue(unknownFile.canRead());
assertTrue(unknownDirectory.isDirectory());
@@ -334,7 +377,11 @@ public class LocalIndexCacheTest extends AbstractIndexUpdaterTest {
updater.fetchAndUpdateIndex(updateRequest);
assertTrue(lockFile.canRead());
- assertFalse(new File(localCacheDir, "nexus-maven-repository-index.1.gz").canRead());
+ assertFalse(localCacheDir
+ .toPath()
+ .resolve("nexus-maven-repository-index.1.gz")
+ .toFile()
+ .canRead());
assertFalse(unknownFile.canRead());
assertFalse(unknownDirectory.isDirectory());
}
diff --git a/indexer-core/src/test/java/org/apache/maven/index/updater/fixtures/ServerTestFixture.java b/indexer-core/src/test/java/org/apache/maven/index/updater/fixtures/ServerTestFixture.java
index 1ae2cbe1..0209d1d2 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/updater/fixtures/ServerTestFixture.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/updater/fixtures/ServerTestFixture.java
@@ -21,6 +21,7 @@ package org.apache.maven.index.updater.fixtures;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
+import java.nio.file.Path;
import java.util.Map;
public class ServerTestFixture {
@@ -48,7 +49,7 @@ public class ServerTestFixture {
throw new IllegalStateException("Cannot find classpath resource: " + SERVER_ROOT_RESOURCE_PATH);
}
- return new File(resource.toURI().normalize());
+ return Path.of(resource.toURI().normalize()).toFile();
}
public void stop() {
diff --git a/indexer-core/src/test/java/org/apache/maven/index/util/SpoofIndexCreator.java b/indexer-core/src/test/java/org/apache/maven/index/util/SpoofIndexCreator.java
index 66ea0110..5ffd2db5 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/util/SpoofIndexCreator.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/util/SpoofIndexCreator.java
@@ -20,7 +20,6 @@ package org.apache.maven.index.util;
import java.io.IOException;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import org.apache.lucene.document.Document;
@@ -35,7 +34,7 @@ public class SpoofIndexCreator extends AbstractIndexCreator {
}
public Collection<IndexerField> getIndexerFields() {
- return Collections.emptyList();
+ return List.of();
}
public void populateArtifactInfo(ArtifactContext artifactContext) throws IOException {
diff --git a/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/SimpleArtifactGenerator.java b/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/SimpleArtifactGenerator.java
index 4736e827..1f7b73a8 100644
--- a/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/SimpleArtifactGenerator.java
+++ b/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/SimpleArtifactGenerator.java
@@ -19,9 +19,10 @@
package org.apache.maven.index.examples;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.security.NoSuchAlgorithmException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -48,13 +49,13 @@ public class SimpleArtifactGenerator {
String classifier,
String extension)
throws IOException, NoSuchAlgorithmException, XmlPullParserException {
- File repositoryDir = new File(repositoryBasedir);
- File artifactFile = new File(
- repositoryDir,
- groupId.replaceAll("\\.", File.separator) + File.separatorChar + artifactId
- + File.separatorChar + version + File.separatorChar + artifactId
- + "-" + version + (classifier != null ? "-" + classifier + File.separatorChar : "")
- + "." + extension);
+ File repositoryDir = Path.of(repositoryBasedir).toFile();
+ File artifactFile = Path.of(
+ repositoryDir.getPath(),
+ groupId.replaceAll("\\.", File.separator) + File.separatorChar + artifactId + File.separatorChar
+ + version + File.separatorChar + artifactId + "-" + version
+ + (classifier != null ? "-" + classifier + File.separatorChar : "") + "." + extension)
+ .toFile();
if (!artifactFile.getParentFile().exists()) {
//noinspection ResultOfMethodCallIgnored
@@ -75,11 +76,14 @@ public class SimpleArtifactGenerator {
//noinspection ResultOfMethodCallIgnored
artifactFile.getParentFile().mkdirs();
- File pomFile = new File(
- artifactFile.getParent(),
- artifactFile.getName().substring(0, artifactFile.getName().lastIndexOf(".")) + ".pom");
+ File pomFile = Path.of(
+ artifactFile.getParent(),
+ artifactFile
+ .getName()
+ .substring(0, artifactFile.getName().lastIndexOf(".")) + ".pom")
+ .toFile();
- zos = new ZipOutputStream(new FileOutputStream(artifactFile));
+ zos = new ZipOutputStream(Files.newOutputStream(artifactFile.toPath()));
generatePom(pomFile, groupId, artifactId, version, extension);
@@ -113,7 +117,7 @@ public class SimpleArtifactGenerator {
ZipEntry ze = new ZipEntry("META-INF/maven/" + groupId + "/" + artifactId + "/" + "pom.xml");
zos.putNextEntry(ze);
- FileInputStream fis = new FileInputStream(pomFile);
+ InputStream fis = Files.newInputStream(pomFile.toPath());
byte[] buffer = new byte[1024];
int len;
diff --git a/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/SpringUsageExampleTest.java b/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/SpringUsageExampleTest.java
index 25295436..44a9d994 100644
--- a/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/SpringUsageExampleTest.java
+++ b/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/SpringUsageExampleTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.index.examples;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.security.NoSuchAlgorithmException;
import java.util.Collection;
@@ -46,7 +47,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@ContextConfiguration(locations = {"/META-INF/spring/*-context.xml", "classpath*:/META-INF/spring/*-context.xml"})
public class SpringUsageExampleTest {
- public static final File REPOSITORIES_BASEDIR = new File("target/repositories");
+ public static final File REPOSITORIES_BASEDIR =
+ Path.of("target/repositories").toFile();
@Autowired
private ArtifactIndexingService artifactIndexingService;
@@ -55,14 +57,17 @@ public class SpringUsageExampleTest {
@BeforeEach
public void setUp() throws Exception {
- if (!new File(REPOSITORIES_BASEDIR, "releases/org/apache/maven/indexer/examples/indexer-examples-spring")
+ if (!REPOSITORIES_BASEDIR
+ .toPath()
+ .resolve("releases/org/apache/maven/indexer/examples/indexer-examples-spring")
+ .toFile()
.exists()) {
//noinspection ResultOfMethodCallIgnored
REPOSITORIES_BASEDIR.mkdirs();
// Generate some valid test artifacts:
generateArtifactAndAddToIndex(
- new File(REPOSITORIES_BASEDIR, "releases").getAbsolutePath(),
+ REPOSITORIES_BASEDIR.toPath().resolve("releases").toFile().getAbsolutePath(),
"releases",
"org.apache.maven.indexer.examples",
"indexer-examples-spring",
@@ -70,7 +75,7 @@ public class SpringUsageExampleTest {
"jar",
null);
generateArtifactAndAddToIndex(
- new File(REPOSITORIES_BASEDIR, "releases").getAbsolutePath(),
+ REPOSITORIES_BASEDIR.toPath().resolve("releases").toFile().getAbsolutePath(),
"releases",
"org.apache.maven.indexer.examples",
"indexer-examples-spring",
@@ -78,7 +83,7 @@ public class SpringUsageExampleTest {
"jar",
null);
generateArtifactAndAddToIndex(
- new File(REPOSITORIES_BASEDIR, "releases").getAbsolutePath(),
+ REPOSITORIES_BASEDIR.toPath().resolve("releases").toFile().getAbsolutePath(),
"releases",
"org.apache.maven.indexer.examples",
"indexer-examples-spring",
@@ -86,7 +91,7 @@ public class SpringUsageExampleTest {
"jar",
null);
generateArtifactAndAddToIndex(
- new File(REPOSITORIES_BASEDIR, "releases").getAbsolutePath(),
+ REPOSITORIES_BASEDIR.toPath().resolve("releases").toFile().getAbsolutePath(),
"releases",
"org.apache.maven.indexer.examples",
"indexer-examples-spring",
@@ -94,7 +99,7 @@ public class SpringUsageExampleTest {
"jar",
null);
generateArtifactAndAddToIndex(
- new File(REPOSITORIES_BASEDIR, "releases").getAbsolutePath(),
+ REPOSITORIES_BASEDIR.toPath().resolve("releases").toFile().getAbsolutePath(),
"releases",
"org.apache.maven.indexer.examples",
"indexer-examples-spring",
@@ -102,7 +107,7 @@ public class SpringUsageExampleTest {
"jar",
null);
generateArtifactAndAddToIndex(
- new File(REPOSITORIES_BASEDIR, "releases").getAbsolutePath(),
+ REPOSITORIES_BASEDIR.toPath().resolve("releases").toFile().getAbsolutePath(),
"releases",
"org.apache.maven.indexer.examples",
"indexer-examples-spring",
diff --git a/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/boot/RepositoryBooter.java b/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/boot/RepositoryBooter.java
index 06eccaae..0e1f8de2 100644
--- a/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/boot/RepositoryBooter.java
+++ b/indexer-examples/indexer-examples-spring/src/test/java/org/apache/maven/index/examples/boot/RepositoryBooter.java
@@ -20,6 +20,7 @@ package org.apache.maven.index.examples.boot;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import jakarta.annotation.PostConstruct;
import org.apache.maven.index.examples.indexing.RepositoryIndexManager;
@@ -52,7 +53,7 @@ public class RepositoryBooter {
@PostConstruct
public void initialize() throws IOException {
- File repositoriesBaseDir = new File("target/repositories");
+ File repositoriesBaseDir = Path.of("target/repositories").toFile();
if (!lockExists(repositoriesBaseDir)) {
createLockFile(repositoriesBaseDir);
@@ -65,7 +66,8 @@ public class RepositoryBooter {
}
private void createLockFile(File repositoriesRootDir) throws IOException {
- final File lockFile = new File(repositoriesRootDir, "repositories.lock");
+ final File lockFile =
+ repositoriesRootDir.toPath().resolve("repositories.lock").toFile();
//noinspection ResultOfMethodCallIgnored
lockFile.getParentFile().mkdirs();
//noinspection ResultOfMethodCallIgnored
@@ -73,7 +75,8 @@ public class RepositoryBooter {
}
private boolean lockExists(File repositoriesRootDir) throws IOException {
- File lockFile = new File(repositoriesRootDir, "repositories.lock");
+ File lockFile =
+ repositoriesRootDir.toPath().resolve("repositories.lock").toFile();
return lockFile.exists();
}
@@ -86,22 +89,27 @@ public class RepositoryBooter {
private void initializeRepository(File repositoriesBaseDir, String repositoryName) throws IOException {
createRepositoryStructure(repositoriesBaseDir.getAbsolutePath(), repositoryName);
- initializeRepositoryIndex(new File(repositoriesBaseDir.getAbsoluteFile(), repositoryName), repositoryName);
+ initializeRepositoryIndex(
+ Path.of(repositoriesBaseDir.getAbsoluteFile().getPath(), repositoryName)
+ .toFile(),
+ repositoryName);
}
public void createRepositoryStructure(String repositoriesBaseDir, String repositoryName) throws IOException {
- final File repositoriesBasedir = new File(repositoriesBaseDir);
+ final File repositoriesBasedir = Path.of(repositoriesBaseDir).toFile();
//noinspection ResultOfMethodCallIgnored
- new File(repositoriesBasedir, repositoryName).mkdirs();
+ Path.of(repositoriesBasedir.getPath(), repositoryName).toFile().mkdirs();
//noinspection ResultOfMethodCallIgnored
- new File(repositoriesBasedir, repositoryName + File.separatorChar + ".index").mkdirs();
+ Path.of(repositoriesBasedir.getPath(), repositoryName + File.separatorChar + ".index")
+ .toFile()
+ .mkdirs();
logger.debug("Created directory structure for repository '" + repositoriesBasedir.getAbsolutePath()
+ File.separatorChar + repositoryName + "'.");
}
private void initializeRepositoryIndex(File repositoryBasedir, String repositoryId) throws IOException {
- final File indexDir = new File(repositoryBasedir, ".index");
+ final File indexDir = repositoryBasedir.toPath().resolve(".index").toFile();
RepositoryIndexer repositoryIndexer =
repositoryIndexerFactory.createRepositoryIndexer(repositoryId, repositoryBasedir, indexDir);
diff --git a/pom.xml b/pom.xml
index 62417c27..fd2ec6f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -280,8 +280,6 @@ under the License.
<version>3.5.0</version>
<configuration>
<javaVersion>${javaVersion}</javaVersion>
- <!-- test sources still use java.io.File throughout; see https://github.com/apache/maven-indexer/issues/591 -->
- <includeTestClasses>false</includeTestClasses>
</configuration>
<executions>
<execution>