You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ab...@apache.org on 2015/04/16 01:02:32 UTC
sqoop git commit: SQOOP-2305: Sqoop2: ConfigUtils is not properly
serializing Enum values
Repository: sqoop
Updated Branches:
refs/heads/sqoop2 d5584f27a -> 36711af54
SQOOP-2305: Sqoop2: ConfigUtils is not properly serializing Enum values
(Jarek Jarcec Cecho via Abraham Elmahrek)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/36711af5
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/36711af5
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/36711af5
Branch: refs/heads/sqoop2
Commit: 36711af547d6d3585bb8f38dd145d0f9ef44ba0b
Parents: d5584f2
Author: Abraham Elmahrek <ab...@apache.org>
Authored: Wed Apr 15 16:01:48 2015 -0700
Committer: Abraham Elmahrek <ab...@apache.org>
Committed: Wed Apr 15 16:01:48 2015 -0700
----------------------------------------------------------------------
common/src/main/java/org/apache/sqoop/model/ConfigUtils.java | 8 +++++++-
.../test/java/org/apache/sqoop/model/TestConfigUtils.java | 4 ++++
2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/36711af5/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
index dd6e9ce..d584079 100644
--- a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
+++ b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
@@ -182,7 +182,13 @@ public class ConfigUtils {
if(value == null) {
input.setEmpty();
} else {
- input.setValue(value);
+ // Some types requires special cast here due to type changes
+ // between Java and model objects
+ if(type.isEnum()) {
+ input.setValue(value.toString());
+ } else {
+ input.setValue(value);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/36711af5/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
index 2cc4965..472bbce 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
@@ -20,6 +20,7 @@ package org.apache.sqoop.model;
import org.testng.annotations.Test;
import org.testng.Assert;
import org.testng.AssertJUnit;
+
import static org.testng.AssertJUnit.assertNull;
import java.util.HashMap;
import java.util.LinkedList;
@@ -38,10 +39,12 @@ public class TestConfigUtils {
public void testConfigs() {
TestConfiguration config = new TestConfiguration();
config.aConfig.a1 = "value";
+ config.cConfig.enumeration = Enumeration.X;
List<MConfig> configsByInstance = ConfigUtils.toConfigs(config);
AssertJUnit.assertEquals(getConfigs(), configsByInstance);
AssertJUnit.assertEquals("value", configsByInstance.get(0).getInputs().get(0).getValue());
+ AssertJUnit.assertEquals("X", configsByInstance.get(2).getInput("cConfig.enumeration").getValue());
List<MConfig> configsByClass = ConfigUtils.toConfigs(TestConfiguration.class);
AssertJUnit.assertEquals(getConfigs(), configsByClass);
@@ -49,6 +52,7 @@ public class TestConfigUtils {
List<MConfig> configsByBoth = ConfigUtils.toConfigs(TestConfiguration.class, config);
AssertJUnit.assertEquals(getConfigs(), configsByBoth);
AssertJUnit.assertEquals("value", configsByBoth.get(0).getInputs().get(0).getValue());
+ AssertJUnit.assertEquals("X", configsByBoth.get(2).getInput("cConfig.enumeration").getValue());
}
@Test(expectedExceptions = SqoopException.class)