sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject sqoop git commit: SQOOP-3380: parquet-configurator-implementation is not recognized as an option
Date Wed, 12 Sep 2018 02:19:47 GMT
Repository: sqoop
Updated Branches:
  refs/heads/trunk c814e5834 -> b37e0c605


SQOOP-3380: parquet-configurator-implementation is not recognized as an option

(Szabolcs Vasas)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/b37e0c60
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/b37e0c60
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/b37e0c60

Branch: refs/heads/trunk
Commit: b37e0c6053b92f2d7a56026e7fde5637b7f70588
Parents: c814e58
Author: Szabolcs Vasas <vasas@apache.org>
Authored: Wed Sep 12 09:19:09 2018 +0700
Committer: Szabolcs Vasas <vasas@apache.org>
Committed: Wed Sep 12 09:19:09 2018 +0700

----------------------------------------------------------------------
 .../org/apache/sqoop/tool/BaseSqoopTool.java    |  5 ++++
 .../apache/sqoop/tool/TestBaseSqoopTool.java    | 28 +++++++++++++++++---
 2 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/b37e0c60/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/tool/BaseSqoopTool.java b/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
index b47be72..955d3a6 100644
--- a/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
+++ b/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
@@ -547,6 +547,11 @@ public abstract class BaseSqoopTool extends org.apache.sqoop.tool.SqoopTool
{
         .hasArg()
         .withArgName("boolean")
         .create());
+    commonOpts.addOption(OptionBuilder
+        .hasArg()
+        .withDescription("The implementation used during Parquet reading/writing")
+        .withLongOpt(PARQUET_CONFIGURATOR_IMPLEMENTATION)
+        .create());
 
     return commonOpts;
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b37e0c60/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java b/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java
index 5571b25..aecfa8b 100644
--- a/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java
+++ b/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java
@@ -19,7 +19,9 @@
 package org.apache.sqoop.tool;
 
 import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
 import org.apache.sqoop.SqoopOptions;
+import org.apache.sqoop.cli.RelatedOptions;
 import org.apache.sqoop.mapreduce.parquet.ParquetJobConfiguratorImplementation;
 import org.junit.Before;
 import org.junit.Rule;
@@ -30,11 +32,14 @@ import org.mockito.Mockito;
 import static org.apache.sqoop.mapreduce.parquet.ParquetJobConfiguratorImplementation.HADOOP;
 import static org.hamcrest.CoreMatchers.sameInstance;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public class TestBaseSqoopTool {
 
+  private static final String PARQUET_CONFIGURATOR_IMPLEMENTATION = "parquet-configurator-implementation";
+
   @Rule
   public ExpectedException exception = ExpectedException.none();
 
@@ -80,7 +85,7 @@ public class TestBaseSqoopTool {
   public void testApplyCommonOptionsSetsParquetJobConfigurationImplementationFromCommandLine()
throws Exception {
     ParquetJobConfiguratorImplementation expectedValue = HADOOP;
 
-    when(mockCommandLine.getOptionValue("parquet-configurator-implementation")).thenReturn(expectedValue.toString());
+    when(mockCommandLine.getOptionValue(PARQUET_CONFIGURATOR_IMPLEMENTATION)).thenReturn(expectedValue.toString());
 
     testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
 
@@ -91,7 +96,7 @@ public class TestBaseSqoopTool {
   public void testApplyCommonOptionsSetsParquetJobConfigurationImplementationFromCommandLineCaseInsensitively()
throws Exception {
     String hadoopImplementationLowercase = "haDooP";
 
-    when(mockCommandLine.getOptionValue("parquet-configurator-implementation")).thenReturn(hadoopImplementationLowercase);
+    when(mockCommandLine.getOptionValue(PARQUET_CONFIGURATOR_IMPLEMENTATION)).thenReturn(hadoopImplementationLowercase);
 
     testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
 
@@ -112,7 +117,7 @@ public class TestBaseSqoopTool {
   public void testApplyCommonOptionsPrefersParquetJobConfigurationImplementationFromCommandLine()
throws Exception {
     ParquetJobConfiguratorImplementation expectedValue = HADOOP;
     testSqoopOptions.getConf().set("parquetjob.configurator.implementation", "kite");
-    when(mockCommandLine.getOptionValue("parquet-configurator-implementation")).thenReturn(expectedValue.toString());
+    when(mockCommandLine.getOptionValue(PARQUET_CONFIGURATOR_IMPLEMENTATION)).thenReturn(expectedValue.toString());
 
     testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
 
@@ -121,7 +126,7 @@ public class TestBaseSqoopTool {
 
   @Test
   public void testApplyCommonOptionsThrowsWhenInvalidParquetJobConfigurationImplementationIsSet()
throws Exception {
-    when(mockCommandLine.getOptionValue("parquet-configurator-implementation")).thenReturn("this_is_definitely_not_valid");
+    when(mockCommandLine.getOptionValue(PARQUET_CONFIGURATOR_IMPLEMENTATION)).thenReturn("this_is_definitely_not_valid");
 
     exception.expectMessage("Invalid Parquet job configurator implementation is set: this_is_definitely_not_valid.
Supported values are: [HADOOP]");
     testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
@@ -133,4 +138,19 @@ public class TestBaseSqoopTool {
 
     assertEquals(HADOOP, testSqoopOptions.getParquetConfiguratorImplementation());
   }
+
+  @Test
+  public void testGetCommonOptionsAddsParquetJobConfigurationImplementation() {
+    RelatedOptions commonOptions = testBaseSqoopTool.getCommonOptions();
+
+    assertTrue(commonOptions.hasOption(PARQUET_CONFIGURATOR_IMPLEMENTATION));
+  }
+
+  @Test
+  public void testParquetJobConfigurationImplementationOptionHasAnArg() {
+    RelatedOptions commonOptions = testBaseSqoopTool.getCommonOptions();
+
+    Option implementationOption = commonOptions.getOption(PARQUET_CONFIGURATOR_IMPLEMENTATION);
+    assertTrue(implementationOption.hasArg());
+  }
 }


Mime
View raw message