rdblue commented on a change in pull request #1531: URL: https://github.com/apache/iceberg/pull/1531#discussion_r499750035
########## File path: core/src/test/java/org/apache/iceberg/TestLocationProvider.java ########## @@ -0,0 +1,164 @@ +/* + * 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.iceberg; + +import java.util.Map; +import org.apache.iceberg.io.LocationProvider; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class TestLocationProvider extends TableTestBase { + @Parameterized.Parameters + public static Object[][] parameters() { + return new Object[][] { + new Object[] { 1 }, + new Object[] { 2 }, + }; + } + + public TestLocationProvider(int formatVersion) { + super(formatVersion); + } + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + // publicly visible for testing to be dynamically loaded + public static class DynamicallyLoadedLocationProvider implements LocationProvider { + String tableLocation; + Map<String, String> properties; + + public DynamicallyLoadedLocationProvider(String tableLocation, Map<String, String> properties) { + this.tableLocation = tableLocation; + this.properties = properties; + } + + @Override + public String newDataLocation(String filename) { + return String.format("%s/test_custom_provider/%s", this.tableLocation, filename); + } + + @Override + public String newDataLocation(PartitionSpec spec, StructLike partitionData, String filename) { + throw new RuntimeException("Test custom provider does not expect any invocation"); + } + } + + // publicly visible for testing to be dynamically loaded + public static class InvalidDynamicallyLoadedLocationProvider implements LocationProvider { + // No public constructor Review comment: Should we support a no-arg constructor as well as the one that passes the table location and properties? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
