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 f6d33aa584..daa78a1eed 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.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 void before(TestInfo testInfo) { 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 dd7d7609f4..cb1bdb67d9 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.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 Map getConfigOverrides() { @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 void before(TestInfo testInfo) { .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 void testValidateNotificationFailToCreateFileIO() { // 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 void testDropTableWithPurge() { .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 f97b3b7299..31549dd0e5 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.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 Map getConfigOverrides() { @Inject CallContext callContext; @Inject RealmConfig realmConfig; @Inject StorageAccessConfigProvider storageAccessConfigProvider; + @Inject FileIOFactory fileIOFactory; private IcebergCatalog catalog; @@ -189,7 +189,6 @@ public void before(TestInfo testInfo) { 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 0370575215..399904f9f4 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.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 void testSendNotificationSufficientPrivileges() { 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 4f83f3f3e8..a60fa10c00 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.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 void before(TestInfo testInfo) { 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 b984ea8239..01479363d7 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.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.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.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 void close() { } }; 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 void close() { @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 void testMetadataFileCleanupIfFileNotExist() throws IOException { @Test public void testCleanupWithRetries() throws IOException { - PolarisCallContext polarisCallContext = newCallContext(); Map retryCounter = new HashMap<>(); FileIO fileIO = new InMemoryFileIO() { @@ -240,9 +246,7 @@ public void deleteFile(String location) { } }; 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 5db3d78622..24d36f27a6 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.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.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 @@ public void testCleanupFileNotExists() throws IOException { @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 @@ public void testCleanupFileManifestExistsDataFilesDontExist() throws IOException @Test public void testCleanupFiles() throws IOException { - PolarisCallContext polarisCallContext = newCallContext(); FileIO fileIO = new InMemoryFileIO() { @Override @@ -126,9 +131,7 @@ public void close() { } }; 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 @@ public void close() { @Test public void testCleanupFilesWithRetries() throws IOException { - PolarisCallContext polarisCallContext = newCallContext(); Map retryCounter = new HashMap<>(); FileIO fileIO = new InMemoryFileIO() { @@ -181,9 +183,7 @@ public void deleteFile(String location) { }; 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 68dd3c1c89..d48c4432fb 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 @@ 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.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 faffe363b9..0000000000 --- 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 properties) { - return fileIO; - } -}