|
@@ -20,6 +20,7 @@ package org.apache.hadoop.tools;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
+import org.apache.hadoop.conf.Configuration;
|
|
|
import org.junit.Assert;
|
|
|
import org.junit.Test;
|
|
|
|
|
@@ -533,4 +534,32 @@ public class TestDistCpOptions {
|
|
|
builder.withLogPath(logPath).withVerboseLog(true);
|
|
|
Assert.assertTrue(builder.build().shouldVerboseLog());
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testAppendToConf() {
|
|
|
+ final int expectedBlocksPerChunk = 999;
|
|
|
+ final String expectedValForEmptyConfigKey = "VALUE_OF_EMPTY_CONFIG_KEY";
|
|
|
+
|
|
|
+ DistCpOptions options = new DistCpOptions.Builder(
|
|
|
+ Collections.singletonList(
|
|
|
+ new Path("hdfs://localhost:8020/source")),
|
|
|
+ new Path("hdfs://localhost:8020/target/"))
|
|
|
+ .withBlocksPerChunk(expectedBlocksPerChunk)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ Configuration config = new Configuration();
|
|
|
+ config.set("", expectedValForEmptyConfigKey);
|
|
|
+
|
|
|
+ options.appendToConf(config);
|
|
|
+ Assert.assertEquals(expectedBlocksPerChunk,
|
|
|
+ config.getInt(
|
|
|
+ DistCpOptionSwitch
|
|
|
+ .BLOCKS_PER_CHUNK
|
|
|
+ .getConfigLabel(), 0));
|
|
|
+ Assert.assertEquals(
|
|
|
+ "Some DistCpOptionSwitch's config label is empty! " +
|
|
|
+ "Pls ensure the config label is provided when apply to config, " +
|
|
|
+ "otherwise it may not be fetched properly",
|
|
|
+ expectedValForEmptyConfigKey, config.get(""));
|
|
|
+ }
|
|
|
}
|