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

dimas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new df6eeaab1 Inject DefaultFileIOFactory in tests (#3043)
df6eeaab1 is described below

commit df6eeaab1cf5b268a8c7493f2e5bd428c4c97ca9
Author: Christopher Lambert <[email protected]>
AuthorDate: Thu Nov 20 16:16:12 2025 +0100

    Inject DefaultFileIOFactory in tests (#3043)
    
    * Inject DefaultFileIOFactory in tests
    
    also simplify `TaskFileIOSupplier` usage in tests, which allows removal
    of `TestFileIOFactory`.
---
 .../AbstractPolarisGenericTableCatalogTest.java    |  4 +-
 .../iceberg/AbstractIcebergCatalogTest.java        | 12 ++---
 .../iceberg/AbstractIcebergCatalogViewTest.java    |  3 +-
 .../iceberg/IcebergCatalogHandlerAuthzTest.java    |  3 +-
 .../catalog/policy/AbstractPolicyCatalogTest.java  |  4 +-
 .../task/BatchFileCleanupTaskHandlerTest.java      | 50 +++++++++++---------
 .../task/ManifestFileCleanupTaskHandlerTest.java   | 54 +++++++++++-----------
 .../service/task/TableCleanupTaskHandlerTest.java  |  8 ++--
 .../apache/polaris/service/TestFileIOFactory.java  | 44 ------------------
 9 files changed, 65 insertions(+), 117 deletions(-)

diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/generic/AbstractPolarisGenericTableCatalogTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/generic/AbstractPolarisGenericTableCatalogTest.java
index f6d33aa58..daa78a1ee 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/generic/AbstractPolarisGenericTableCatalogTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/generic/AbstractPolarisGenericTableCatalogTest.java
@@ -64,7 +64,6 @@ import 
org.apache.polaris.core.storage.cache.StorageCredentialCache;
 import org.apache.polaris.service.admin.PolarisAdminService;
 import org.apache.polaris.service.catalog.PolarisPassthroughResolutionView;
 import org.apache.polaris.service.catalog.iceberg.IcebergCatalog;
-import org.apache.polaris.service.catalog.io.DefaultFileIOFactory;
 import org.apache.polaris.service.catalog.io.FileIOFactory;
 import org.apache.polaris.service.catalog.io.StorageAccessConfigProvider;
 import org.apache.polaris.service.config.ReservedProperties;
@@ -106,6 +105,7 @@ public abstract class 
AbstractPolarisGenericTableCatalogTest {
   @Inject CallContext callContext;
   @Inject RealmConfig realmConfig;
   @Inject StorageAccessConfigProvider storageAccessConfigProvider;
+  @Inject FileIOFactory fileIOFactory;
 
   private PolarisGenericTableCatalog genericTableCatalog;
   private IcebergCatalog icebergCatalog;
@@ -113,7 +113,6 @@ public abstract class 
AbstractPolarisGenericTableCatalogTest {
   private String realmName;
   private PolarisCallContext polarisContext;
   private PolarisAdminService adminService;
-  private FileIOFactory fileIOFactory;
   private PolarisPrincipal authenticatedRoot;
   private PolarisEntity catalogEntity;
 
@@ -195,7 +194,6 @@ public abstract class 
AbstractPolarisGenericTableCatalogTest {
         new PolarisPassthroughResolutionView(
             resolutionManifestFactory, authenticatedRoot, CATALOG_NAME);
     TaskExecutor taskExecutor = Mockito.mock();
-    this.fileIOFactory = new DefaultFileIOFactory();
 
     StsClient stsClient = Mockito.mock(StsClient.class);
     when(stsClient.assumeRole(isA(AssumeRoleRequest.class)))
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogTest.java
index dd7d7609f..cb1bdb67d 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogTest.java
@@ -134,7 +134,6 @@ import 
org.apache.polaris.core.storage.cache.StorageCredentialCache;
 import org.apache.polaris.service.admin.PolarisAdminService;
 import org.apache.polaris.service.catalog.PolarisPassthroughResolutionView;
 import org.apache.polaris.service.catalog.Profiles;
-import org.apache.polaris.service.catalog.io.DefaultFileIOFactory;
 import org.apache.polaris.service.catalog.io.ExceptionMappingFileIO;
 import org.apache.polaris.service.catalog.io.FileIOFactory;
 import org.apache.polaris.service.catalog.io.MeasuredFileIOFactory;
@@ -238,13 +237,14 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
   @Inject RealmConfig realmConfig;
   @Inject ResolutionManifestFactory resolutionManifestFactory;
   @Inject StorageAccessConfigProvider storageAccessConfigProvider;
+  @Inject FileIOFactory fileIOFactory;
+  @Inject TaskFileIOSupplier taskFileIOSupplier;
 
   private IcebergCatalog catalog;
   private String realmName;
   private PolarisCallContext polarisContext;
   private PolarisAdminService adminService;
   private ResolverFactory resolverFactory;
-  private FileIOFactory fileIOFactory;
   private InMemoryFileIO fileIO;
   private PolarisEntity catalogEntity;
   private PolarisPrincipal authenticatedRoot;
@@ -338,8 +338,6 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
                     .build()
                     .asCatalog(serviceIdentityProvider)));
 
-    this.fileIOFactory = new DefaultFileIOFactory();
-
     StsClient stsClient = Mockito.mock(StsClient.class);
     when(stsClient.assumeRole(isA(AssumeRoleRequest.class)))
         .thenReturn(
@@ -983,7 +981,7 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
     // filename.
     final String tableLocation = 
"s3://externally-owned-bucket/validate_table/";
     final String tableMetadataLocation = tableLocation + "metadata/";
-    FileIOFactory fileIOFactory = spy(new DefaultFileIOFactory());
+    FileIOFactory fileIOFactory = spy(this.fileIOFactory);
     IcebergCatalog catalog = newIcebergCatalog(catalog().name(), 
metaStoreManager, fileIOFactory);
     catalog.initialize(
         CATALOG_NAME,
@@ -1899,9 +1897,7 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
         .containsEntry(StorageAccessProperty.AWS_KEY_ID.getPropertyName(), 
TEST_ACCESS_KEY)
         .containsEntry(StorageAccessProperty.AWS_SECRET_KEY.getPropertyName(), 
SECRET_ACCESS_KEY)
         .containsEntry(StorageAccessProperty.AWS_TOKEN.getPropertyName(), 
SESSION_TOKEN);
-    FileIO fileIO =
-        new TaskFileIOSupplier(new DefaultFileIOFactory(), 
storageAccessConfigProvider)
-            .apply(taskEntity, TABLE);
+    FileIO fileIO = taskFileIOSupplier.apply(taskEntity, TABLE);
     
Assertions.assertThat(fileIO).isNotNull().isInstanceOf(ExceptionMappingFileIO.class);
     Assertions.assertThat(((ExceptionMappingFileIO) fileIO).getInnerIo())
         .isInstanceOf(InMemoryFileIO.class);
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogViewTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogViewTest.java
index f97b3b729..31549dd0e 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogViewTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogViewTest.java
@@ -55,7 +55,6 @@ import 
org.apache.polaris.core.storage.cache.StorageCredentialCache;
 import org.apache.polaris.service.admin.PolarisAdminService;
 import org.apache.polaris.service.catalog.PolarisPassthroughResolutionView;
 import org.apache.polaris.service.catalog.Profiles;
-import org.apache.polaris.service.catalog.io.DefaultFileIOFactory;
 import org.apache.polaris.service.catalog.io.FileIOFactory;
 import org.apache.polaris.service.catalog.io.StorageAccessConfigProvider;
 import org.apache.polaris.service.config.ReservedProperties;
@@ -113,6 +112,7 @@ public abstract class AbstractIcebergCatalogViewTest 
extends ViewCatalogTests<Ic
   @Inject CallContext callContext;
   @Inject RealmConfig realmConfig;
   @Inject StorageAccessConfigProvider storageAccessConfigProvider;
+  @Inject FileIOFactory fileIOFactory;
 
   private IcebergCatalog catalog;
 
@@ -189,7 +189,6 @@ public abstract class AbstractIcebergCatalogViewTest 
extends ViewCatalogTests<Ic
     PolarisPassthroughResolutionView passthroughView =
         new PolarisPassthroughResolutionView(
             resolutionManifestFactory, authenticatedRoot, CATALOG_NAME);
-    FileIOFactory fileIOFactory = new DefaultFileIOFactory();
 
     testPolarisEventListener = (TestPolarisEventListener) polarisEventListener;
     testPolarisEventListener.clear();
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerAuthzTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerAuthzTest.java
index 037057521..399904f9f 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerAuthzTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerAuthzTest.java
@@ -69,7 +69,6 @@ import org.apache.polaris.core.entity.PrincipalEntity;
 import org.apache.polaris.core.persistence.dao.entity.CreatePrincipalResult;
 import org.apache.polaris.core.persistence.resolver.PolarisResolutionManifest;
 import org.apache.polaris.service.admin.PolarisAuthzTestBase;
-import org.apache.polaris.service.catalog.io.DefaultFileIOFactory;
 import org.apache.polaris.service.context.catalog.CallContextCatalogFactory;
 import 
org.apache.polaris.service.context.catalog.PolarisCallContextCatalogFactory;
 import org.apache.polaris.service.http.IfNoneMatch;
@@ -1891,7 +1890,7 @@ public class IcebergCatalogHandlerAuthzTest extends 
PolarisAuthzTestBase {
             resolverFactory,
             Mockito.mock(),
             storageAccessConfigProvider,
-            new DefaultFileIOFactory(),
+            fileIOFactory,
             polarisEventListener,
             metaStoreManager,
             callContext,
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/policy/AbstractPolicyCatalogTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/policy/AbstractPolicyCatalogTest.java
index 4f83f3f3e..a60fa10c0 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/policy/AbstractPolicyCatalogTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/policy/AbstractPolicyCatalogTest.java
@@ -76,7 +76,6 @@ import 
org.apache.polaris.core.storage.cache.StorageCredentialCache;
 import org.apache.polaris.service.admin.PolarisAdminService;
 import org.apache.polaris.service.catalog.PolarisPassthroughResolutionView;
 import org.apache.polaris.service.catalog.iceberg.IcebergCatalog;
-import org.apache.polaris.service.catalog.io.DefaultFileIOFactory;
 import org.apache.polaris.service.catalog.io.FileIOFactory;
 import org.apache.polaris.service.catalog.io.StorageAccessConfigProvider;
 import org.apache.polaris.service.config.ReservedProperties;
@@ -132,6 +131,7 @@ public abstract class AbstractPolicyCatalogTest {
   @Inject CallContext callContext;
   @Inject RealmConfig realmConfig;
   @Inject StorageAccessConfigProvider storageAccessConfigProvider;
+  @Inject FileIOFactory fileIOFactory;
 
   private PolicyCatalog policyCatalog;
   private IcebergCatalog icebergCatalog;
@@ -139,7 +139,6 @@ public abstract class AbstractPolicyCatalogTest {
   private String realmName;
   private PolarisCallContext polarisContext;
   private PolarisAdminService adminService;
-  private FileIOFactory fileIOFactory;
   private PolarisPrincipal authenticatedRoot;
   private PolarisEntity catalogEntity;
 
@@ -214,7 +213,6 @@ public abstract class AbstractPolicyCatalogTest {
         new PolarisPassthroughResolutionView(
             resolutionManifestFactory, authenticatedRoot, CATALOG_NAME);
     TaskExecutor taskExecutor = Mockito.mock();
-    this.fileIOFactory = new DefaultFileIOFactory();
 
     StsClient stsClient = Mockito.mock(StsClient.class);
     when(stsClient.assumeRole(isA(AssumeRoleRequest.class)))
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/task/BatchFileCleanupTaskHandlerTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/task/BatchFileCleanupTaskHandlerTest.java
index b984ea823..01479363d 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/task/BatchFileCleanupTaskHandlerTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/task/BatchFileCleanupTaskHandlerTest.java
@@ -22,6 +22,8 @@ import static 
org.apache.polaris.service.task.TaskTestUtils.addTaskLocation;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatPredicate;
 
+import io.quarkus.test.InjectMock;
+import io.quarkus.test.junit.QuarkusMock;
 import io.quarkus.test.junit.QuarkusTest;
 import jakarta.inject.Inject;
 import java.io.IOException;
@@ -30,6 +32,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Stream;
@@ -43,34 +46,43 @@ import org.apache.iceberg.catalog.TableIdentifier;
 import org.apache.iceberg.inmemory.InMemoryFileIO;
 import org.apache.iceberg.io.FileIO;
 import org.apache.polaris.core.PolarisCallContext;
+import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.AsyncTaskType;
 import org.apache.polaris.core.entity.TaskEntity;
-import org.apache.polaris.core.persistence.BasePersistence;
-import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
-import org.apache.polaris.service.TestFileIOFactory;
-import org.apache.polaris.service.catalog.io.StorageAccessConfigProvider;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
 @QuarkusTest
 public class BatchFileCleanupTaskHandlerTest {
-  @Inject MetaStoreManagerFactory metaStoreManagerFactory;
+  @Inject CallContext callContext;
+  @InjectMock TaskFileIOSupplier taskFileIOSupplier;
+
   private final RealmContext realmContext = () -> "realmName";
+  private PolarisCallContext polarisCallContext;
+  private ExecutorService executor;
+
+  @BeforeEach
+  public void beforeEach() {
+    QuarkusMock.installMockForType(realmContext, RealmContext.class);
+    polarisCallContext = callContext.getPolarisCallContext();
+    executor = Executors.newSingleThreadExecutor();
+  }
 
-  private TaskFileIOSupplier buildTaskFileIOSupplier(FileIO fileIO) {
-    return new TaskFileIOSupplier(
-        new TestFileIOFactory(fileIO), 
Mockito.mock(StorageAccessConfigProvider.class));
+  @AfterEach
+  public void afterEach() {
+    executor.close();
   }
 
-  private PolarisCallContext newCallContext() {
-    BasePersistence metaStore = 
metaStoreManagerFactory.getOrCreateSession(realmContext);
-    return new PolarisCallContext(realmContext, metaStore);
+  private BatchFileCleanupTaskHandler newBatchFileCleanupTaskHandler(FileIO 
fileIO) {
+    Mockito.when(taskFileIOSupplier.apply(Mockito.any(), 
Mockito.any())).thenReturn(fileIO);
+    return new BatchFileCleanupTaskHandler(taskFileIOSupplier, executor);
   }
 
   @Test
   public void testMetadataFileCleanup() throws IOException {
-    PolarisCallContext polarisCallContext = newCallContext();
     FileIO fileIO =
         new InMemoryFileIO() {
           @Override
@@ -79,9 +91,7 @@ public class BatchFileCleanupTaskHandlerTest {
           }
         };
     TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", 
"schema1"), "table1");
-    BatchFileCleanupTaskHandler handler =
-        new BatchFileCleanupTaskHandler(
-            buildTaskFileIOSupplier(fileIO), 
Executors.newSingleThreadExecutor());
+    BatchFileCleanupTaskHandler handler = 
newBatchFileCleanupTaskHandler(fileIO);
 
     long snapshotId1 = 100L;
     ManifestFile manifestFile1 =
@@ -179,12 +189,9 @@ public class BatchFileCleanupTaskHandlerTest {
 
   @Test
   public void testMetadataFileCleanupIfFileNotExist() throws IOException {
-    PolarisCallContext polarisCallContext = newCallContext();
     FileIO fileIO = new InMemoryFileIO();
     TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", 
"schema1"), "table1");
-    BatchFileCleanupTaskHandler handler =
-        new BatchFileCleanupTaskHandler(
-            buildTaskFileIOSupplier(fileIO), 
Executors.newSingleThreadExecutor());
+    BatchFileCleanupTaskHandler handler = 
newBatchFileCleanupTaskHandler(fileIO);
     long snapshotId = 100L;
     ManifestFile manifestFile =
         TaskTestUtils.manifestFile(
@@ -219,7 +226,6 @@ public class BatchFileCleanupTaskHandlerTest {
 
   @Test
   public void testCleanupWithRetries() throws IOException {
-    PolarisCallContext polarisCallContext = newCallContext();
     Map<String, AtomicInteger> retryCounter = new HashMap<>();
     FileIO fileIO =
         new InMemoryFileIO() {
@@ -240,9 +246,7 @@ public class BatchFileCleanupTaskHandlerTest {
           }
         };
     TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", 
"schema1"), "table1");
-    BatchFileCleanupTaskHandler handler =
-        new BatchFileCleanupTaskHandler(
-            buildTaskFileIOSupplier(fileIO), 
Executors.newSingleThreadExecutor());
+    BatchFileCleanupTaskHandler handler = 
newBatchFileCleanupTaskHandler(fileIO);
     long snapshotId = 100L;
     ManifestFile manifestFile =
         TaskTestUtils.manifestFile(
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/task/ManifestFileCleanupTaskHandlerTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/task/ManifestFileCleanupTaskHandlerTest.java
index 5db3d7862..24d36f27a 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/task/ManifestFileCleanupTaskHandlerTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/task/ManifestFileCleanupTaskHandlerTest.java
@@ -23,12 +23,15 @@ import static 
org.apache.polaris.service.task.TaskTestUtils.addTaskLocation;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatPredicate;
 
+import io.quarkus.test.InjectMock;
+import io.quarkus.test.junit.QuarkusMock;
 import io.quarkus.test.junit.QuarkusTest;
 import jakarta.inject.Inject;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.iceberg.ManifestFile;
@@ -39,41 +42,47 @@ import org.apache.iceberg.io.FileIO;
 import org.apache.iceberg.io.OutputFile;
 import org.apache.iceberg.io.PositionOutputStream;
 import org.apache.polaris.core.PolarisCallContext;
+import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.AsyncTaskType;
 import org.apache.polaris.core.entity.TaskEntity;
-import org.apache.polaris.core.persistence.BasePersistence;
-import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
-import org.apache.polaris.service.TestFileIOFactory;
-import org.apache.polaris.service.catalog.io.StorageAccessConfigProvider;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
 @QuarkusTest
 class ManifestFileCleanupTaskHandlerTest {
-  @Inject MetaStoreManagerFactory metaStoreManagerFactory;
+  @Inject CallContext callContext;
+  @InjectMock TaskFileIOSupplier taskFileIOSupplier;
 
   private final RealmContext realmContext = () -> "realmName";
+  private PolarisCallContext polarisCallContext;
+  private ExecutorService executor;
 
-  private TaskFileIOSupplier buildTaskFileIOSupplier(FileIO fileIO) {
-    return new TaskFileIOSupplier(
-        new TestFileIOFactory(fileIO), 
Mockito.mock(StorageAccessConfigProvider.class));
+  @BeforeEach
+  public void beforeEach() {
+    QuarkusMock.installMockForType(realmContext, RealmContext.class);
+    polarisCallContext = callContext.getPolarisCallContext();
+    executor = Executors.newSingleThreadExecutor();
   }
 
-  private PolarisCallContext newCallContext() {
-    BasePersistence metaStore = 
metaStoreManagerFactory.getOrCreateSession(realmContext);
-    return new PolarisCallContext(realmContext, metaStore);
+  @AfterEach
+  public void afterEach() {
+    executor.close();
+  }
+
+  private ManifestFileCleanupTaskHandler 
newManifestFileCleanupTaskHandler(FileIO fileIO) {
+    Mockito.when(taskFileIOSupplier.apply(Mockito.any(), 
Mockito.any())).thenReturn(fileIO);
+    return new ManifestFileCleanupTaskHandler(taskFileIOSupplier, executor);
   }
 
   @Test
   public void testCleanupFileNotExists() throws IOException {
-    PolarisCallContext polarisCallContext = newCallContext();
     FileIO fileIO = new InMemoryFileIO();
     TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", 
"schema1"), "table1");
 
-    ManifestFileCleanupTaskHandler handler =
-        new ManifestFileCleanupTaskHandler(
-            buildTaskFileIOSupplier(fileIO), 
Executors.newSingleThreadExecutor());
+    ManifestFileCleanupTaskHandler handler = 
newManifestFileCleanupTaskHandler(fileIO);
     ManifestFile manifestFile =
         TaskTestUtils.manifestFile(
             fileIO, "manifest1.avro", 1L, "dataFile1.parquet", 
"dataFile2.parquet");
@@ -93,12 +102,9 @@ class ManifestFileCleanupTaskHandlerTest {
 
   @Test
   public void testCleanupFileManifestExistsDataFilesDontExist() throws 
IOException {
-    PolarisCallContext polarisCallContext = newCallContext();
     FileIO fileIO = new InMemoryFileIO();
     TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", 
"schema1"), "table1");
-    ManifestFileCleanupTaskHandler handler =
-        new ManifestFileCleanupTaskHandler(
-            buildTaskFileIOSupplier(fileIO), 
Executors.newSingleThreadExecutor());
+    ManifestFileCleanupTaskHandler handler = 
newManifestFileCleanupTaskHandler(fileIO);
     ManifestFile manifestFile =
         TaskTestUtils.manifestFile(
             fileIO, "manifest1.avro", 100L, "dataFile1.parquet", 
"dataFile2.parquet");
@@ -117,7 +123,6 @@ class ManifestFileCleanupTaskHandlerTest {
 
   @Test
   public void testCleanupFiles() throws IOException {
-    PolarisCallContext polarisCallContext = newCallContext();
     FileIO fileIO =
         new InMemoryFileIO() {
           @Override
@@ -126,9 +131,7 @@ class ManifestFileCleanupTaskHandlerTest {
           }
         };
     TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", 
"schema1"), "table1");
-    ManifestFileCleanupTaskHandler handler =
-        new ManifestFileCleanupTaskHandler(
-            buildTaskFileIOSupplier(fileIO), 
Executors.newSingleThreadExecutor());
+    ManifestFileCleanupTaskHandler handler = 
newManifestFileCleanupTaskHandler(fileIO);
     String dataFile1Path = "dataFile1.parquet";
     OutputFile dataFile1 = fileIO.newOutputFile(dataFile1Path);
     PositionOutputStream out1 = dataFile1.createOrOverwrite();
@@ -158,7 +161,6 @@ class ManifestFileCleanupTaskHandlerTest {
 
   @Test
   public void testCleanupFilesWithRetries() throws IOException {
-    PolarisCallContext polarisCallContext = newCallContext();
     Map<String, AtomicInteger> retryCounter = new HashMap<>();
     FileIO fileIO =
         new InMemoryFileIO() {
@@ -181,9 +183,7 @@ class ManifestFileCleanupTaskHandlerTest {
         };
 
     TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", 
"schema1"), "table1");
-    ManifestFileCleanupTaskHandler handler =
-        new ManifestFileCleanupTaskHandler(
-            buildTaskFileIOSupplier(fileIO), 
Executors.newSingleThreadExecutor());
+    ManifestFileCleanupTaskHandler handler = 
newManifestFileCleanupTaskHandler(fileIO);
     String dataFile1Path = "dataFile1.parquet";
     OutputFile dataFile1 = fileIO.newOutputFile(dataFile1Path);
     PositionOutputStream out1 = dataFile1.createOrOverwrite();
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/task/TableCleanupTaskHandlerTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/task/TableCleanupTaskHandlerTest.java
index 68dd3c1c8..d48c4432f 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/task/TableCleanupTaskHandlerTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/task/TableCleanupTaskHandlerTest.java
@@ -21,6 +21,7 @@ package org.apache.polaris.service.task;
 import static org.apache.polaris.service.task.TaskTestUtils.addTaskLocation;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import io.quarkus.test.InjectMock;
 import io.quarkus.test.junit.QuarkusMock;
 import io.quarkus.test.junit.QuarkusTest;
 import jakarta.inject.Inject;
@@ -48,8 +49,6 @@ import 
org.apache.polaris.core.entity.table.IcebergTableLikeEntity;
 import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
 import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
 import org.apache.polaris.core.persistence.pagination.PageToken;
-import org.apache.polaris.service.TestFileIOFactory;
-import org.apache.polaris.service.catalog.io.StorageAccessConfigProvider;
 import org.assertj.core.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -62,13 +61,12 @@ class TableCleanupTaskHandlerTest {
   @Inject MetaStoreManagerFactory metaStoreManagerFactory;
   @Inject PolarisMetaStoreManager metaStoreManager;
   @Inject CallContext callContext;
+  @InjectMock TaskFileIOSupplier taskFileIOSupplier;
 
   private final RealmContext realmContext = () -> "realmName";
 
   private TableCleanupTaskHandler newTableCleanupTaskHandler(FileIO fileIO) {
-    TaskFileIOSupplier taskFileIOSupplier =
-        new TaskFileIOSupplier(
-            new TestFileIOFactory(fileIO), 
Mockito.mock(StorageAccessConfigProvider.class));
+    Mockito.when(taskFileIOSupplier.apply(Mockito.any(), 
Mockito.any())).thenReturn(fileIO);
     return new TableCleanupTaskHandler(
         Mockito.mock(), clock, metaStoreManagerFactory, taskFileIOSupplier);
   }
diff --git 
a/runtime/service/src/testFixtures/java/org/apache/polaris/service/TestFileIOFactory.java
 
b/runtime/service/src/testFixtures/java/org/apache/polaris/service/TestFileIOFactory.java
deleted file mode 100644
index faffe363b..000000000
--- 
a/runtime/service/src/testFixtures/java/org/apache/polaris/service/TestFileIOFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.polaris.service;
-
-import jakarta.annotation.Nonnull;
-import java.util.Map;
-import org.apache.iceberg.io.FileIO;
-import org.apache.polaris.core.storage.StorageAccessConfig;
-import org.apache.polaris.service.catalog.io.FileIOFactory;
-
-/** A FileIOFactory that always returns the same FileIO instance. */
-public class TestFileIOFactory implements FileIOFactory {
-
-  private final FileIO fileIO;
-
-  public TestFileIOFactory(@Nonnull FileIO fileIO) {
-    this.fileIO = fileIO;
-  }
-
-  @Override
-  public FileIO loadFileIO(
-      @Nonnull StorageAccessConfig accessConfig,
-      @Nonnull String ioImplClassName,
-      @Nonnull Map<String, String> properties) {
-    return fileIO;
-  }
-}

Reply via email to