You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2015/02/05 17:36:58 UTC
[2/2] sqoop git commit: SQOOP-1804: Add editable and override
attribute to inputs
SQOOP-1804: Add editable and override attribute to inputs
(Veena Basavaraj via Jarek Jarcec Cecho)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/6fc50b08
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/6fc50b08
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/6fc50b08
Branch: refs/heads/sqoop2
Commit: 6fc50b08b0b4bc18305c829c4abc9bbcdbbd34b6
Parents: 433a42d
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Thu Feb 5 08:35:44 2015 -0800
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Thu Feb 5 08:35:44 2015 -0800
----------------------------------------------------------------------
.../sqoop/error/code/CommonRepositoryError.java | 15 +-
.../sqoop/json/util/ConfigInputConstants.java | 4 +-
.../json/util/ConfigInputSerialization.java | 20 +-
.../org/apache/sqoop/model/ConfigUtils.java | 59 +++-
.../main/java/org/apache/sqoop/model/Input.java | 17 +
.../org/apache/sqoop/model/InputEditable.java | 41 +++
.../org/apache/sqoop/model/MBooleanInput.java | 8 +-
.../java/org/apache/sqoop/model/MConfig.java | 21 +-
.../java/org/apache/sqoop/model/MEnumInput.java | 10 +-
.../java/org/apache/sqoop/model/MInput.java | 30 +-
.../org/apache/sqoop/model/MIntegerInput.java | 8 +-
.../java/org/apache/sqoop/model/MMapInput.java | 8 +-
.../org/apache/sqoop/model/MStringInput.java | 10 +-
.../java/org/apache/sqoop/model/ModelError.java | 10 +
.../apache/sqoop/json/util/ConfigTestUtil.java | 40 ++-
.../json/util/TestConfigSerialization.java | 14 +-
.../org/apache/sqoop/model/TestConfigUtils.java | 259 +++++++++++---
.../sqoop/model/TestMAccountableEntity.java | 3 +-
.../apache/sqoop/model/TestMBooleanInput.java | 25 +-
.../org/apache/sqoop/model/TestMConfig.java | 23 +-
.../org/apache/sqoop/model/TestMConfigList.java | 11 +-
.../org/apache/sqoop/model/TestMConnector.java | 5 +-
.../org/apache/sqoop/model/TestMEnumInput.java | 14 +-
.../apache/sqoop/model/TestMIntegerInput.java | 21 +-
.../java/org/apache/sqoop/model/TestMJob.java | 9 +-
.../java/org/apache/sqoop/model/TestMLink.java | 5 +-
.../org/apache/sqoop/model/TestMMapInput.java | 21 +-
.../apache/sqoop/model/TestMNamedElement.java | 3 +-
.../apache/sqoop/model/TestMStringInput.java | 25 +-
.../sqoop/model/TestMValidatedElement.java | 5 +-
.../jdbc/TestGenericJdbcConnectorUpgrader.java | 39 ++-
.../sqoop/driver/TestDriverConfigUpgrader.java | 18 +-
.../common/CommonRepositoryHandler.java | 298 +++++++++++-----
...RepositoryInsertUpdateDeleteSelectQuery.java | 62 +++-
.../common/CommonRepositorySchemaConstants.java | 13 +
.../derby/DerbyRepositoryHandler.java | 7 +-
.../repository/derby/DerbySchemaConstants.java | 9 +
.../derby/DerbySchemaCreateQuery.java | 27 ++
.../derby/DerbySchemaUpgradeQuery.java | 7 +-
.../sqoop/repository/derby/DerbyTestCase.java | 349 ++++++++++++++-----
.../repository/derby/TestConnectorHandling.java | 20 +-
.../repository/derby/TestDriverHandling.java | 6 +
.../sqoop/repository/derby/TestInputTypes.java | 50 ++-
.../postgresql/PostgresqlTestCase.java | 9 +-
.../org/apache/sqoop/shell/core/Constants.java | 4 +
.../sqoop/shell/utils/ConfigDisplayer.java | 5 +
.../apache/sqoop/shell/utils/ConfigFiller.java | 3 +-
.../main/resources/shell-resource.properties | 2 +
48 files changed, 1264 insertions(+), 408 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/error/code/CommonRepositoryError.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/error/code/CommonRepositoryError.java b/common/src/main/java/org/apache/sqoop/error/code/CommonRepositoryError.java
index 952be3f..74e5de3 100644
--- a/common/src/main/java/org/apache/sqoop/error/code/CommonRepositoryError.java
+++ b/common/src/main/java/org/apache/sqoop/error/code/CommonRepositoryError.java
@@ -181,7 +181,20 @@ public enum CommonRepositoryError implements ErrorCode {
COMMON_0043("Could not set connector direction"),
/** The system was unable to register driver due to a server error **/
- COMMON_0044("Registration of driver failed")
+ COMMON_0044("Registration of driver failed"),
+
+ /**
+ * Config Input that is set to USER_ONLY editable cannot override other
+ * USER_ONLY input
+ **/
+ COMMON_0045("Config Input cannot override USER_ONLY attribute"),
+
+ /** Config Input cannot override itself */
+ COMMON_0046("Config Input cannot override itself"),
+
+ COMMON_0047("Config Input relation insertion failed"),
+
+ COMMON_0048("Config Input overrides could not be fetched"),
;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/json/util/ConfigInputConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/ConfigInputConstants.java b/common/src/main/java/org/apache/sqoop/json/util/ConfigInputConstants.java
index 5d261de..21739da 100644
--- a/common/src/main/java/org/apache/sqoop/json/util/ConfigInputConstants.java
+++ b/common/src/main/java/org/apache/sqoop/json/util/ConfigInputConstants.java
@@ -36,8 +36,10 @@ public class ConfigInputConstants {
public static final String CONFIG_INPUT_TYPE = "type";
public static final String CONFIG_INPUT_SENSITIVE = "sensitive";
public static final String CONFIG_INPUT_SIZE = "size";
+ public static final String CONFIG_INPUT_EDITABLE = "editable";
+ public static final String CONFIG_INPUT_OVERRIDES = "overrides";
public static final String CONFIG_INPUT_VALUE = "value";
- public static final String CONFIG_INPUT_VALUES = "values";
+ public static final String CONFIG_INPUT_ENUM_VALUES = "values";
private ConfigInputConstants() {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java b/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java
index 8b11ed5..f671447 100644
--- a/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java
+++ b/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java
@@ -21,6 +21,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.sqoop.classification.InterfaceAudience;
import org.apache.sqoop.classification.InterfaceStability;
import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.InputEditable;
import org.apache.sqoop.model.MBooleanInput;
import org.apache.sqoop.model.MEnumInput;
import org.apache.sqoop.model.MConfig;
@@ -83,6 +84,8 @@ public final class ConfigInputSerialization {
input.put(ConfigInputConstants.CONFIG_INPUT_NAME, mInput.getName());
input.put(ConfigInputConstants.CONFIG_INPUT_TYPE, mInput.getType().toString());
input.put(ConfigInputConstants.CONFIG_INPUT_SENSITIVE, mInput.isSensitive());
+ input.put(ConfigInputConstants.CONFIG_INPUT_EDITABLE, mInput.getEditable().name());
+ input.put(ConfigInputConstants.CONFIG_INPUT_OVERRIDES, mInput.getOverrides());
// String specific serialization
if (mInput.getType() == MInputType.STRING) {
@@ -92,7 +95,7 @@ public final class ConfigInputSerialization {
// Enum specific serialization
if(mInput.getType() == MInputType.ENUM) {
- input.put(ConfigInputConstants.CONFIG_INPUT_VALUES,
+ input.put(ConfigInputConstants.CONFIG_INPUT_ENUM_VALUES,
StringUtils.join(((MEnumInput)mInput).getValues(), ","));
}
@@ -145,28 +148,31 @@ public final class ConfigInputSerialization {
MInputType.valueOf((String) input.get(ConfigInputConstants.CONFIG_INPUT_TYPE));
String name = (String) input.get(ConfigInputConstants.CONFIG_INPUT_NAME);
Boolean sensitive = (Boolean) input.get(ConfigInputConstants.CONFIG_INPUT_SENSITIVE);
+ InputEditable editable = InputEditable.valueOf((String)input.get(ConfigInputConstants.CONFIG_INPUT_EDITABLE));
+ String overrides = (String) input.get(ConfigInputConstants.CONFIG_INPUT_OVERRIDES);
+
MInput mInput = null;
switch (type) {
case STRING: {
long size = (Long) input.get(ConfigInputConstants.CONFIG_INPUT_SIZE);
- mInput = new MStringInput(name, sensitive.booleanValue(), (short) size);
+ mInput = new MStringInput(name, sensitive.booleanValue(), editable, overrides, (short) size);
break;
}
case MAP: {
- mInput = new MMapInput(name, sensitive.booleanValue());
+ mInput = new MMapInput(name, sensitive.booleanValue(), editable, overrides);
break;
}
case INTEGER: {
- mInput = new MIntegerInput(name, sensitive.booleanValue());
+ mInput = new MIntegerInput(name, sensitive.booleanValue(), editable, overrides);
break;
}
case BOOLEAN: {
- mInput = new MBooleanInput(name, sensitive.booleanValue());
+ mInput = new MBooleanInput(name, sensitive.booleanValue(), editable, overrides);
break;
}
case ENUM: {
- String values = (String) input.get(ConfigInputConstants.CONFIG_INPUT_VALUES);
- mInput = new MEnumInput(name, sensitive.booleanValue(), values.split(","));
+ String values = (String) input.get(ConfigInputConstants.CONFIG_INPUT_ENUM_VALUES);
+ mInput = new MEnumInput(name, sensitive.booleanValue(), editable, overrides, values.split(","));
break;
}
default:
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/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 279f3a6..1ec763b 100644
--- a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
+++ b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
@@ -21,6 +21,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.sqoop.classification.InterfaceAudience;
import org.apache.sqoop.classification.InterfaceStability;
import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.error.code.CommonRepositoryError;
import org.apache.sqoop.json.JSONUtils;
import org.apache.sqoop.utils.ClassUtils;
import org.apache.sqoop.validation.ConfigValidationRunner;
@@ -29,6 +30,7 @@ import org.apache.sqoop.validation.ConfigValidationResult;
import org.json.simple.JSONObject;
import java.lang.reflect.Field;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -137,6 +139,8 @@ public class ConfigUtils {
if(inputAnnotation != null) {
boolean sensitive = inputAnnotation.sensitive();
short maxLen = inputAnnotation.size();
+ InputEditable editable = inputAnnotation.editable();
+ String overrides = inputAnnotation.overrides();
Class<?> type = field.getType();
MInput input;
@@ -149,15 +153,15 @@ public class ConfigUtils {
// Instantiate corresponding MInput<?> structure
if (type == String.class) {
- input = new MStringInput(inputName, sensitive, maxLen);
+ input = new MStringInput(inputName, sensitive, editable, overrides, maxLen);
} else if (type.isAssignableFrom(Map.class)) {
- input = new MMapInput(inputName, sensitive);
+ input = new MMapInput(inputName, sensitive, editable, overrides);
} else if (type == Integer.class) {
- input = new MIntegerInput(inputName, sensitive);
+ input = new MIntegerInput(inputName, sensitive, editable, overrides);
} else if (type == Boolean.class) {
- input = new MBooleanInput(inputName, sensitive);
+ input = new MBooleanInput(inputName, sensitive, editable, overrides);
} else if (type.isEnum()) {
- input = new MEnumInput(inputName, sensitive,
+ input = new MEnumInput(inputName, sensitive, editable, overrides,
ClassUtils.getEnumStrings(type));
} else {
throw new SqoopException(ModelError.MODEL_004, "Unsupported type "
@@ -183,8 +187,13 @@ public class ConfigUtils {
inputs.add(input);
}
}
+ MConfig config = new MConfig(configName, inputs);
+ // validation has to happen only when all inputs have been parsed
+ for (MInput<?> input : config.getInputs()) {
+ validateInputOverridesAttribute(input, config);
+ }
- return new MConfig(configName, inputs);
+ return config;
}
private static Field getFieldFromName(Class<?> klass, String name) {
@@ -631,4 +640,42 @@ public class ConfigUtils {
throw new SqoopException(ModelError.MODEL_015, e);
}
}
+
+ /**
+ * Validate that the input override attribute adheres to the rules imposed
+ * NOTE: all input names in a config class will and must be unique, check the name exists and it is not self override
+ * Rule #1.
+ * If editable == USER_ONLY ( cannot override itself ) can override other CONNECTOR_ONLY and ANY inputs,
+ * but cannot overriding other USER_ONLY attributes
+ * Rule #2.
+ * If editable == CONNECTOR_ONLY or ANY ( cannot override itself ) can override any other attribute in the config object
+ * @param currentInput
+ *
+ */
+ public static void validateInputOverridesAttribute(MInput<?> currentInput, MConfig config) {
+
+ // split the overrides string into comma separated list
+ String overrides = currentInput.getOverrides();
+ if (StringUtils.isEmpty(overrides)) {
+ return;
+ }
+ String[] overrideInputs = overrides.split("\\,");
+ for (String override : overrideInputs) {
+ if (!config.getInputNames().contains(override)) {
+ throw new SqoopException(ModelError.MODEL_017, "for input :"
+ + currentInput.toString());
+ }
+ if (override.equals(currentInput.getName())) {
+ throw new SqoopException(ModelError.MODEL_018, "for input :"
+ + currentInput.toString());
+ }
+ if (currentInput.getEditable().equals(InputEditable.USER_ONLY)) {
+ if (config.getUserOnlyEditableInputNames().contains(override)) {
+ throw new SqoopException(ModelError.MODEL_019, "for input :"
+ + currentInput.toString());
+ }
+ }
+ }
+ return;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/Input.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/Input.java b/common/src/main/java/org/apache/sqoop/model/Input.java
index b6305f2..883abe6 100644
--- a/common/src/main/java/org/apache/sqoop/model/Input.java
+++ b/common/src/main/java/org/apache/sqoop/model/Input.java
@@ -43,6 +43,15 @@ public @interface Input {
boolean sensitive() default false;
/**
+ * Indicates the entity that can edit the input's values, all inputs are
+ * created/deleted only by the connector code, other entities do not have
+ * access to either create/delete an input
+ *
+ * @return editable
+ */
+ InputEditable editable() default InputEditable.ANY;
+
+ /**
* Maximal length of field if applicable.
*
* @return Maximal length
@@ -50,9 +59,17 @@ public @interface Input {
short size() default -1;
/**
+ * In-order to express dependency on other inputs, the value supports a comma
+ * separated list of other inputs in the config class. It validates the
+ * attribute value obeys the expected conditions
+ */
+ String overrides() default "";
+
+ /**
* List of validators associated with this input.
*
* @return
*/
Validator[] validators() default {};
+
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/InputEditable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/InputEditable.java b/common/src/main/java/org/apache/sqoop/model/InputEditable.java
new file mode 100644
index 0000000..3589dfc
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/InputEditable.java
@@ -0,0 +1,41 @@
+/**
+ * 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.sqoop.model;
+
+/**
+ * Various supported roles for editing input values that belong to a config
+ * NOTE: In future this can be extended based on the roles supported in sqoop
+ * for instance, we could have sqoop ADMIN_ONLY editable inputs
+ */
+public enum InputEditable {
+ /**
+ * Sqoop user alone can edit the input values via rest API or shell command line
+ */
+ USER_ONLY,
+
+ /**
+ * Connector code alone can edit the input values
+ */
+ CONNECTOR_ONLY,
+
+ /**
+ * Either Connector code or the sqoop user alone can edit the input values
+ */
+
+ ANY
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/MBooleanInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MBooleanInput.java b/common/src/main/java/org/apache/sqoop/model/MBooleanInput.java
index c7fcf90..d55a0e7 100644
--- a/common/src/main/java/org/apache/sqoop/model/MBooleanInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MBooleanInput.java
@@ -27,8 +27,8 @@ import org.apache.sqoop.classification.InterfaceStability;
@InterfaceStability.Unstable
public class MBooleanInput extends MInput<Boolean> {
- public MBooleanInput(String name, boolean sensitive) {
- super(name, sensitive);
+ public MBooleanInput(String name, boolean sensitive, InputEditable editable, String overrides) {
+ super(name, sensitive, editable, overrides);
}
@Override
@@ -78,8 +78,8 @@ public class MBooleanInput extends MInput<Boolean> {
@Override
public Object clone(boolean cloneWithValue) {
- MBooleanInput copy = new MBooleanInput(getName(), isSensitive());
- copy.setPersistenceId(this.getPersistenceId());
+ MBooleanInput copy = new MBooleanInput(getName(), isSensitive(), getEditable(), getOverrides());
+ copy.setPersistenceId(getPersistenceId());
if(cloneWithValue) {
copy.setValue(getValue());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/MConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConfig.java b/common/src/main/java/org/apache/sqoop/model/MConfig.java
index d128441..1bae6d4 100644
--- a/common/src/main/java/org/apache/sqoop/model/MConfig.java
+++ b/common/src/main/java/org/apache/sqoop/model/MConfig.java
@@ -22,7 +22,9 @@ import org.apache.sqoop.classification.InterfaceStability;
import org.apache.sqoop.common.SqoopException;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
/**
* Represents a group of inputs that are processed together. This allows the
@@ -34,17 +36,34 @@ import java.util.List;
public final class MConfig extends MValidatedElement implements MClonable {
private final List<MInput<?>> inputs;
+ private Set<String> inputNames = new HashSet<String>();
+ private Set<String> userOnlyEditableInputNames = new HashSet<String>();
public MConfig(String name, List<MInput<?>> inputs) {
super(name);
-
this.inputs = inputs;
+ if (inputs != null && inputs.size() > 0) {
+ for (MInput<?> input : inputs) {
+ inputNames.add(input.getName());
+ if (input.getEditable().equals(InputEditable.USER_ONLY)) {
+ userOnlyEditableInputNames.add(input.getName());
+ }
+ }
+ }
}
public List<MInput<?>> getInputs() {
return inputs;
}
+ public Set<String> getInputNames() {
+ return inputNames;
+ }
+
+ public Set<String> getUserOnlyEditableInputNames() {
+ return userOnlyEditableInputNames;
+ }
+
public MInput<?> getInput(String inputName) {
for(MInput<?> input: inputs) {
if(inputName.equals(input.getName())) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MEnumInput.java b/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
index 74838fc..e630536 100644
--- a/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
@@ -36,8 +36,8 @@ public class MEnumInput extends MInput<String> {
*/
String []values;
- public MEnumInput(String name, boolean sensitive, String[] values) {
- super(name, sensitive);
+ public MEnumInput(String name, boolean sensitive, InputEditable editable, String overrides, String[] values) {
+ super(name, sensitive, editable, overrides);
this.values = values;
}
@@ -131,9 +131,9 @@ public class MEnumInput extends MInput<String> {
@Override
public MEnumInput clone(boolean cloneWithValue) {
- MEnumInput copy = new MEnumInput(this.getName(),
- this.isSensitive(), this.getValues());
- copy.setPersistenceId(this.getPersistenceId());
+ MEnumInput copy = new MEnumInput(getName(), isSensitive(), getEditable(), getOverrides(),
+ getValues());
+ copy.setPersistenceId(getPersistenceId());
if(cloneWithValue) {
copy.setValue(this.getValue());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/MInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MInput.java b/common/src/main/java/org/apache/sqoop/model/MInput.java
index d1c2ab6..d5ce074 100644
--- a/common/src/main/java/org/apache/sqoop/model/MInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MInput.java
@@ -31,15 +31,22 @@ import org.apache.sqoop.classification.InterfaceStability;
public abstract class MInput<T> extends MValidatedElement implements MClonable {
private final boolean sensitive;
+ private final String overrides;
+
+ private final InputEditable editable;
+
private T value;
- protected MInput(String name, boolean sensitive) {
+ protected MInput(String name, boolean sensitive, InputEditable editable, String overrides) {
super(name);
this.sensitive = sensitive;
+ this.editable = editable;
+ this.overrides = overrides;
}
/**
- * @param value the value to be set for this parameter
+ * @param value
+ * the value to be set for this parameter
*/
public void setValue(T value) {
this.value = value;
@@ -60,6 +67,22 @@ public abstract class MInput<T> extends MValidatedElement implements MClonable {
}
/**
+ * @return the editable {@link#InputEditable}attribute for the input
+ */
+ public InputEditable getEditable() {
+ return editable;
+ }
+
+ /**
+ * @return the overrides attribute for the input
+ * An input can override the value of one or more other inputs when edited
+ */
+ public String getOverrides() {
+ return overrides;
+ }
+
+ /**
+ /**
* @return a URL-safe string representation of the value
*/
public abstract String getUrlSafeValueString();
@@ -127,7 +150,8 @@ public abstract class MInput<T> extends MValidatedElement implements MClonable {
public final String toString() {
StringBuilder sb = new StringBuilder("input-").append(getName());
sb.append(":").append(getPersistenceId()).append(":");
- sb.append(getType());
+ sb.append(getType()).append(":").append(isSensitive()).append(":").append(getEditable().name())
+ .append(":").append(getOverrides());
if (hasExtraInfo()) {
sb.append(":").append(getExtraInfoToString());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java b/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java
index de50cd4..90b2d95 100644
--- a/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java
@@ -29,8 +29,8 @@ import org.apache.sqoop.classification.InterfaceStability;
@InterfaceStability.Unstable
public class MIntegerInput extends MInput<Integer> {
- public MIntegerInput(String name, boolean sensitive) {
- super(name, sensitive);
+ public MIntegerInput(String name, boolean sensitive, InputEditable editable, String overrides) {
+ super(name, sensitive, editable, overrides);
}
@Override
@@ -87,8 +87,8 @@ public class MIntegerInput extends MInput<Integer> {
@Override
public MIntegerInput clone(boolean cloneWithValue) {
- MIntegerInput copy = new MIntegerInput(this.getName(), this.isSensitive());
- copy.setPersistenceId(this.getPersistenceId());
+ MIntegerInput copy = new MIntegerInput(getName(), isSensitive(), getEditable(), getOverrides());
+ copy.setPersistenceId(getPersistenceId());
if(cloneWithValue) {
copy.setValue(this.getValue());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/MMapInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MMapInput.java b/common/src/main/java/org/apache/sqoop/model/MMapInput.java
index cf781b2..ce0f0f7 100644
--- a/common/src/main/java/org/apache/sqoop/model/MMapInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MMapInput.java
@@ -29,8 +29,8 @@ import org.apache.sqoop.utils.UrlSafeUtils;
@InterfaceStability.Unstable
public final class MMapInput extends MInput<Map<String, String>> {
- public MMapInput(String name, boolean sensitive) {
- super(name, sensitive);
+ public MMapInput(String name, boolean sensitive, InputEditable editable, String overrides) {
+ super(name, sensitive, editable, overrides);
}
@Override
@@ -114,8 +114,8 @@ public final class MMapInput extends MInput<Map<String, String>> {
@Override
public MMapInput clone(boolean cloneWithValue) {
- MMapInput copy = new MMapInput(this.getName(), this.isSensitive());
- copy.setPersistenceId(this.getPersistenceId());
+ MMapInput copy = new MMapInput(getName(), isSensitive(), getEditable(), getOverrides());
+ copy.setPersistenceId(getPersistenceId());
if(cloneWithValue && this.getValue() != null) {
Map<String, String> copyMap = new HashMap<String, String>();
Set<Map.Entry<String, String>> entry = this.getValue().entrySet();
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/MStringInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MStringInput.java b/common/src/main/java/org/apache/sqoop/model/MStringInput.java
index 4854838..7365098 100644
--- a/common/src/main/java/org/apache/sqoop/model/MStringInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MStringInput.java
@@ -38,8 +38,8 @@ public final class MStringInput extends MInput<String> {
* @param sensitive a flag indicating if the string should be masked
* @param maxLength the maximum length of the string
*/
- public MStringInput(String name, boolean sensitive, short maxLength) {
- super(name, sensitive);
+ public MStringInput(String name, boolean sensitive, InputEditable editable, String overrides, short maxLength) {
+ super(name, sensitive, editable, overrides);
this.maxLength = maxLength;
}
@@ -111,9 +111,9 @@ public final class MStringInput extends MInput<String> {
@Override
public MStringInput clone(boolean cloneWithValue) {
- MStringInput copy = new MStringInput(this.getName(),
- this.isSensitive(), this.getMaxLength());
- copy.setPersistenceId(this.getPersistenceId());
+ MStringInput copy = new MStringInput(getName(), isSensitive(), getEditable(), getOverrides(),
+ getMaxLength());
+ copy.setPersistenceId(getPersistenceId());
if(cloneWithValue) {
copy.setValue(this.getValue());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/main/java/org/apache/sqoop/model/ModelError.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/ModelError.java b/common/src/main/java/org/apache/sqoop/model/ModelError.java
index dcb137a..17e70df 100644
--- a/common/src/main/java/org/apache/sqoop/model/ModelError.java
+++ b/common/src/main/java/org/apache/sqoop/model/ModelError.java
@@ -60,6 +60,16 @@ public enum ModelError implements ErrorCode {
MODEL_016("Can't instantiate class"),
+ MODEL_017("Config Input override name does nto exist"),
+ /**
+ * Config Input that is set to USER_ONLY editable cannot override other
+ * USER_ONLY input
+ **/
+ MODEL_018("Config Input cannot override USER_ONLY attribute"),
+
+ /** Config Input cannot override itself */
+ MODEL_019("Config Input cannot override itself"),
+
;
private final String message;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/json/util/ConfigTestUtil.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/ConfigTestUtil.java b/common/src/test/java/org/apache/sqoop/json/util/ConfigTestUtil.java
index 7f0e2f1..fbc7faa 100644
--- a/common/src/test/java/org/apache/sqoop/json/util/ConfigTestUtil.java
+++ b/common/src/test/java/org/apache/sqoop/json/util/ConfigTestUtil.java
@@ -23,6 +23,8 @@ import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
+import org.apache.commons.lang.StringUtils;
+import org.apache.sqoop.model.InputEditable;
import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MDriverConfig;
import org.apache.sqoop.model.MFromConfig;
@@ -42,11 +44,11 @@ public class ConfigTestUtil {
List<MConfig> driverConfigs = new ArrayList<MConfig>();
inputs = new ArrayList<MInput<?>>();
- input = new MIntegerInput("numExtractors", false);
+ input = new MIntegerInput("numExtractors", false, InputEditable.ANY, StringUtils.EMPTY);
input.setPersistenceId(1);
inputs.add(input);
- input = new MIntegerInput("numLoaders", false);
+ input = new MIntegerInput("numLoaders", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
input.setPersistenceId(2);
inputs.add(input);
@@ -63,16 +65,16 @@ public class ConfigTestUtil {
List<MConfig> linkConfig = new ArrayList<MConfig>();
inputs = new ArrayList<MInput<?>>();
- input = new MStringInput("url", false, (short) 10);
+ input = new MStringInput("url", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(1);
inputs.add(input);
- input = new MStringInput("username", false, (short) 10);
+ input = new MStringInput("username", false, InputEditable.USER_ONLY, "password", (short) 10);
input.setPersistenceId(2);
input.setValue("test");
inputs.add(input);
- input = new MStringInput("password", true, (short) 10);
+ input = new MStringInput("password", true, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(3);
input.setValue("test");
inputs.add(input);
@@ -92,33 +94,33 @@ public class ConfigTestUtil {
inputs = new ArrayList<MInput<?>>();
- input = new MStringInput("A", false, (short) 10);
+ input = new MStringInput("A", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(4);
inputs.add(input);
- input = new MStringInput("B", false, (short) 10);
+ input = new MStringInput("B", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(5);
inputs.add(input);
- input = new MStringInput("C", false, (short) 10);
+ input = new MStringInput("C", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(6);
inputs.add(input);
config = new MConfig("Z", inputs);
config.setPersistenceId(11);
- jobConfigs.add(config);
+ jobConfigs.add(config);
inputs = new ArrayList<MInput<?>>();
- input = new MStringInput("D", false, (short) 10);
+ input = new MStringInput("D", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(7);
inputs.add(input);
- input = new MStringInput("E", false, (short) 10);
+ input = new MStringInput("E", false, InputEditable.USER_ONLY, "D, F", (short) 10);
input.setPersistenceId(8);
inputs.add(input);
- input = new MStringInput("F", false, (short) 10);
+ input = new MStringInput("F", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(9);
inputs.add(input);
@@ -137,15 +139,15 @@ public class ConfigTestUtil {
inputs = new ArrayList<MInput<?>>();
- input = new MStringInput("A", false, (short) 10);
+ input = new MStringInput("A", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(4);
inputs.add(input);
- input = new MStringInput("B", false, (short) 10);
+ input = new MStringInput("B", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(5);
inputs.add(input);
- input = new MStringInput("C", false, (short) 10);
+ input = new MStringInput("C", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(6);
inputs.add(input);
@@ -155,17 +157,17 @@ public class ConfigTestUtil {
inputs = new ArrayList<MInput<?>>();
- input = new MStringInput("D", false, (short) 10);
+ input = new MStringInput("D", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(7);
inputs.add(input);
- input = new MStringInput("E", false, (short) 10);
+ input = new MStringInput("E", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(8);
inputs.add(input);
- input = new MStringInput("F", false, (short) 10);
+ input = new MStringInput("F", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
input.setPersistenceId(9);
- inputs.add(input);
+ inputs.add(input);
config = new MConfig("to-table", inputs);
config.setPersistenceId(12);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
index 10ac3cf..18a1d4f 100644
--- a/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
+++ b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
@@ -25,8 +25,10 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang.StringUtils;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.json.JSONUtils;
+import org.apache.sqoop.model.InputEditable;
import org.apache.sqoop.model.MBooleanInput;
import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MConfigType;
@@ -121,7 +123,7 @@ public class TestConfigSerialization {
inputs = new LinkedList<MInput<?>>();
- input = new MMapInput("Map", false);
+ input = new MMapInput("Map", false, InputEditable.ANY, StringUtils.EMPTY);
inputs.add(input);
return new MConfig("c", inputs);
@@ -138,19 +140,19 @@ public class TestConfigSerialization {
inputs = new LinkedList<MInput<?>>();
- input = new MStringInput("String", false, (short)30);
+ input = new MStringInput("String", false, InputEditable.ANY, StringUtils.EMPTY, (short)30);
inputs.add(input);
- input = new MMapInput("Map", false);
+ input = new MMapInput("Map", false, InputEditable.ANY, StringUtils.EMPTY);
inputs.add(input);
- input = new MIntegerInput("Integer", false);
+ input = new MIntegerInput("Integer", false, InputEditable.ANY, StringUtils.EMPTY);
inputs.add(input);
- input = new MBooleanInput("Boolean", false);
+ input = new MBooleanInput("Boolean", false, InputEditable.ANY, StringUtils.EMPTY);
inputs.add(input);
- input = new MEnumInput("Enum", false, new String[] {"YES", "NO"});
+ input = new MEnumInput("Enum", false, InputEditable.ANY, StringUtils.EMPTY, new String[] {"YES", "NO"});
inputs.add(input);
return new MConfig("c", inputs);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/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 64ffdd1..7eafdf4 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
@@ -17,125 +17,160 @@
*/
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;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-
+import org.apache.commons.lang.StringUtils;
import org.apache.sqoop.common.SqoopException;
/**
* Test config utils
*/
-public class TestConfigUtils extends TestCase {
+public class TestConfigUtils {
+ @Test
public void testConfigs() {
TestConfiguration config = new TestConfiguration();
config.aConfig.a1 = "value";
List<MConfig> configsByInstance = ConfigUtils.toConfigs(config);
- assertEquals(getConfigs(), configsByInstance);
- assertEquals("value", configsByInstance.get(0).getInputs().get(0).getValue());
+ AssertJUnit.assertEquals(getConfigs(), configsByInstance);
+ AssertJUnit.assertEquals("value", configsByInstance.get(0).getInputs().get(0).getValue());
List<MConfig> configsByClass = ConfigUtils.toConfigs(TestConfiguration.class);
- assertEquals(getConfigs(), configsByClass);
+ AssertJUnit.assertEquals(getConfigs(), configsByClass);
List<MConfig> configsByBoth = ConfigUtils.toConfigs(TestConfiguration.class, config);
- assertEquals(getConfigs(), configsByBoth);
- assertEquals("value", configsByBoth.get(0).getInputs().get(0).getValue());
+ AssertJUnit.assertEquals(getConfigs(), configsByBoth);
+ AssertJUnit.assertEquals("value", configsByBoth.get(0).getInputs().get(0).getValue());
+ }
+
+ @Test(expectedExceptions = SqoopException.class)
+ public void testBadConfigInputsWithNonExisitingOverride() {
+ TestBadConfiguration config = new TestBadConfiguration();
+ config.aBadConfig.a1 = "value";
+ ConfigUtils.toConfigs(config);
+ }
+
+ @Test(expectedExceptions = SqoopException.class)
+ public void testBadConfigInputsWithBadOverride() {
+ TestBadConfiguration1 config = new TestBadConfiguration1();
+ config.aBadConfig1.a1 = "value";
+ ConfigUtils.toConfigs(config);
+ }
+
+ @Test(expectedExceptions = SqoopException.class)
+ public void testBadConfigInputsWithSelfOverride() {
+ TestBadConfiguration2 config = new TestBadConfiguration2();
+ config.aBadConfig2.a1 = "value";
+ ConfigUtils.toConfigs(config);
}
+ @Test
public void testConfigsMissingAnnotation() {
try {
ConfigUtils.toConfigs(ConfigWithoutAnnotation.class);
- } catch(SqoopException ex) {
- assertEquals(ModelError.MODEL_003, ex.getErrorCode());
+ } catch (SqoopException ex) {
+ AssertJUnit.assertEquals(ModelError.MODEL_003, ex.getErrorCode());
return;
}
- fail("Correct exception wasn't thrown");
+ Assert.fail("Correct exception wasn't thrown");
}
+ @Test
public void testNonUniqueConfigNameAttributes() {
try {
ConfigUtils.toConfigs(ConfigurationWithNonUniqueConfigNameAttribute.class);
} catch (SqoopException ex) {
- assertEquals(ModelError.MODEL_012, ex.getErrorCode());
+ AssertJUnit.assertEquals(ModelError.MODEL_012, ex.getErrorCode());
return;
}
- fail("Correct exception wasn't thrown");
+ Assert.fail("Correct exception wasn't thrown");
}
+ @Test
public void testInvalidConfigNameAttribute() {
try {
ConfigUtils.toConfigs(ConfigurationWithInvalidConfigNameAttribute.class);
} catch (SqoopException ex) {
- assertEquals(ModelError.MODEL_013, ex.getErrorCode());
+ AssertJUnit.assertEquals(ModelError.MODEL_013, ex.getErrorCode());
return;
}
- fail("Correct exception wasn't thrown");
+ Assert.fail("Correct exception wasn't thrown");
}
+ @Test
public void testInvalidConfigNameAttributeLength() {
try {
ConfigUtils.toConfigs(ConfigurationWithInvalidConfigNameAttributeLength.class);
} catch (SqoopException ex) {
- assertEquals(ModelError.MODEL_014, ex.getErrorCode());
+ AssertJUnit.assertEquals(ModelError.MODEL_014, ex.getErrorCode());
return;
}
- fail("Correct exception wasn't thrown");
+ Assert.fail("Correct exception wasn't thrown");
}
+ @Test
public void testFailureOnPrimitiveType() {
PrimitiveConfig config = new PrimitiveConfig();
try {
ConfigUtils.toConfigs(config);
- fail("We were expecting exception for unsupported type.");
- } catch(SqoopException ex) {
- assertEquals(ModelError.MODEL_007, ex.getErrorCode());
+ Assert.fail("We were expecting exception for unsupported type.");
+ } catch (SqoopException ex) {
+ AssertJUnit.assertEquals(ModelError.MODEL_007, ex.getErrorCode());
}
}
+ @Test
public void testFillValues() {
List<MConfig> configs = getConfigs();
- ((MStringInput)configs.get(0).getInputs().get(0)).setValue("value");
+ ((MStringInput) configs.get(0).getInputs().get(0)).setValue("value");
TestConfiguration config = new TestConfiguration();
ConfigUtils.fromConfigs(configs, config);
- assertEquals("value", config.aConfig.a1);
+ AssertJUnit.assertEquals("value", config.aConfig.a1);
}
+ @Test
public void testFromConfigWithClass() {
List<MConfig> configs = getConfigs();
- ((MStringInput)configs.get(0).getInputs().get(0)).setValue("value");
+ ((MStringInput) configs.get(0).getInputs().get(0)).setValue("value");
- TestConfiguration config = (TestConfiguration) ConfigUtils.fromConfigs(configs, TestConfiguration.class);
- assertEquals("value", config.aConfig.a1);
+ TestConfiguration config = (TestConfiguration) ConfigUtils.fromConfigs(configs,
+ TestConfiguration.class);
+ AssertJUnit.assertEquals("value", config.aConfig.a1);
}
+ @Test
public void testFillValuesObjectReuse() {
List<MConfig> configs = getConfigs();
- ((MStringInput)configs.get(0).getInputs().get(0)).setValue("value");
+ ((MStringInput) configs.get(0).getInputs().get(0)).setValue("value");
TestConfiguration config = new TestConfiguration();
config.aConfig.a2 = "x";
config.bConfig.b1 = "y";
ConfigUtils.fromConfigs(configs, config);
- assertEquals("value", config.aConfig.a1);
+ AssertJUnit.assertEquals("value", config.aConfig.a1);
assertNull(config.aConfig.a2);
assertNull(config.bConfig.b2);
assertNull(config.bConfig.b2);
}
+ @Test
public void testJson() {
TestConfiguration config = new TestConfiguration();
config.aConfig.a1 = "A";
@@ -156,17 +191,17 @@ public class TestConfigUtils extends TestCase {
ConfigUtils.fillValues(json, targetConfig);
- assertEquals("A", targetConfig.aConfig.a1);
+ AssertJUnit.assertEquals("A", targetConfig.aConfig.a1);
assertNull(targetConfig.aConfig.a2);
assertNull(targetConfig.bConfig.b1);
- assertEquals("B", targetConfig.bConfig.b2);
+ AssertJUnit.assertEquals("B", targetConfig.bConfig.b2);
- assertEquals((Integer)4, targetConfig.cConfig.intValue);
- assertEquals(1, targetConfig.cConfig.map.size());
- assertTrue(targetConfig.cConfig.map.containsKey("C"));
- assertEquals("D", targetConfig.cConfig.map.get("C"));
- assertEquals(Enumeration.X, targetConfig.cConfig.enumeration);
+ AssertJUnit.assertEquals((Integer) 4, targetConfig.cConfig.intValue);
+ AssertJUnit.assertEquals(1, targetConfig.cConfig.map.size());
+ AssertJUnit.assertTrue(targetConfig.cConfig.map.containsKey("C"));
+ AssertJUnit.assertEquals("D", targetConfig.cConfig.map.get("C"));
+ AssertJUnit.assertEquals(Enumeration.X, targetConfig.cConfig.enumeration);
}
/**
@@ -180,26 +215,70 @@ public class TestConfigUtils extends TestCase {
// Config A
inputs = new LinkedList<MInput<?>>();
- inputs.add(new MStringInput("aConfig.a1", false, (short)30));
- inputs.add(new MStringInput("aConfig.a2", true, (short)-1));
+ inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, StringUtils.EMPTY,
+ (short) 30));
+ inputs.add(new MStringInput("aConfig.a2", true, InputEditable.ANY, StringUtils.EMPTY,
+ (short) -1));
ret.add(new MConfig("aConfig", inputs));
// Config B
inputs = new LinkedList<MInput<?>>();
- inputs.add(new MStringInput("bConfig.b1", false, (short)2));
- inputs.add(new MStringInput("bConfig.b2", false, (short)3));
+ inputs.add(new MStringInput("bConfig.b1", false, InputEditable.ANY, StringUtils.EMPTY,
+ (short) 2));
+ inputs.add(new MStringInput("bConfig.b2", false, InputEditable.ANY, StringUtils.EMPTY,
+ (short) 3));
ret.add(new MConfig("bConfig", inputs));
// Config C
inputs = new LinkedList<MInput<?>>();
- inputs.add(new MIntegerInput("cConfig.intValue", false));
- inputs.add(new MMapInput("cConfig.map", false));
- inputs.add(new MEnumInput("cConfig.enumeration", false, new String[]{"X", "Y"}));
+ inputs.add(new MIntegerInput("cConfig.intValue", false, InputEditable.ANY, StringUtils.EMPTY));
+ inputs.add(new MMapInput("cConfig.map", false, InputEditable.ANY, StringUtils.EMPTY));
+ inputs.add(new MEnumInput("cConfig.enumeration", false, InputEditable.ANY, StringUtils.EMPTY,
+ new String[] { "X", "Y" }));
ret.add(new MConfig("cConfig", inputs));
return ret;
}
+ protected List<MConfig> getBadConfigWithSelfOverrideInputs() {
+ List<MConfig> ret = new LinkedList<MConfig>();
+
+ List<MInput<?>> inputs;
+ // Config A
+ inputs = new LinkedList<MInput<?>>();
+ inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, "aConfig.a1", (short) 30));
+ inputs.add(new MStringInput("aConfig.a2", true, InputEditable.ANY, StringUtils.EMPTY,
+ (short) -1));
+ ret.add(new MConfig("aConfig", inputs));
+ return ret;
+ }
+
+ protected List<MConfig> getBadConfigWithNonExistingOverrideInputs() {
+ List<MConfig> ret = new LinkedList<MConfig>();
+
+ List<MInput<?>> inputs;
+ // Config A
+ inputs = new LinkedList<MInput<?>>();
+ inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, "aConfig.a3", (short) 30));
+ inputs.add(new MStringInput("aConfig.a2", true, InputEditable.ANY, StringUtils.EMPTY,
+ (short) -1));
+ ret.add(new MConfig("aConfig", inputs));
+ return ret;
+ }
+
+ protected List<MConfig> getBadConfigWithUserEditableOverrideInputs() {
+ List<MConfig> ret = new LinkedList<MConfig>();
+
+ List<MInput<?>> inputs;
+ // Config A
+ inputs = new LinkedList<MInput<?>>();
+ inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, "aConfig.a2", (short) 30));
+ inputs.add(new MStringInput("aConfig.a2", true, InputEditable.USER_ONLY, StringUtils.EMPTY,
+ (short) -1));
+ ret.add(new MConfig("aConfig", inputs));
+ return ret;
+ }
+
@ConfigurationClass
public static class ConfigurationWithNonUniqueConfigNameAttribute {
public ConfigurationWithNonUniqueConfigNameAttribute() {
@@ -234,6 +313,39 @@ public class TestConfigUtils extends TestCase {
}
@ConfigurationClass
+ public static class TestBadConfiguration {
+
+ public TestBadConfiguration() {
+ aBadConfig = new ABadConfig();
+ }
+
+ @Config
+ ABadConfig aBadConfig;
+ }
+
+ @ConfigurationClass
+ public static class TestBadConfiguration1 {
+
+ public TestBadConfiguration1() {
+ aBadConfig1 = new ABadConfig1();
+ }
+
+ @Config
+ ABadConfig1 aBadConfig1;
+ }
+
+ @ConfigurationClass
+ public static class TestBadConfiguration2 {
+
+ public TestBadConfiguration2() {
+ aBadConfig2 = new ABadConfig2();
+ }
+
+ @Config
+ ABadConfig2 aBadConfig2;
+ }
+
+ @ConfigurationClass
public static class TestConfiguration {
public TestConfiguration() {
@@ -242,33 +354,68 @@ public class TestConfigUtils extends TestCase {
cConfig = new CConfig();
}
- @Config AConfig aConfig;
- @Config BConfig bConfig;
- @Config CConfig cConfig;
+ @Config
+ AConfig aConfig;
+ @Config
+ BConfig bConfig;
+ @Config
+ CConfig cConfig;
}
@ConfigurationClass
public static class PrimitiveConfig {
- @Config DConfig dConfig;
+ @Config
+ DConfig dConfig;
}
@ConfigClass
public static class AConfig {
- @Input(size = 30) String a1;
- @Input(sensitive = true) String a2;
+ @Input(size = 30)
+ String a1;
+ @Input(sensitive = true)
+ String a2;
+ }
+
+ @ConfigClass
+ public static class ABadConfig {
+ @Input(size = 30, editable = InputEditable.USER_ONLY, overrides = "a5")
+ String a1;
+ @Input(sensitive = true)
+ String a2;
+ }
+
+ @ConfigClass
+ public static class ABadConfig1 {
+ @Input(size = 30, editable = InputEditable.USER_ONLY, overrides = "a2")
+ String a1;
+ @Input(sensitive = true, editable = InputEditable.USER_ONLY, overrides = "a1")
+ String a2;
+ }
+
+ @ConfigClass
+ public static class ABadConfig2 {
+ @Input(size = 30, editable = InputEditable.USER_ONLY, overrides = "a1")
+ String a1;
+ @Input(sensitive = true, editable = InputEditable.USER_ONLY, overrides = "a2")
+ String a2;
}
@ConfigClass
public static class BConfig {
- @Input(size = 2) String b1;
- @Input(size = 3) String b2;
+ @Input(size = 2)
+ String b1;
+ @Input(size = 3)
+ String b2;
}
@ConfigClass
public static class CConfig {
- @Input Integer intValue;
- @Input Map<String, String> map;
- @Input Enumeration enumeration;
+ @Input
+ Integer intValue;
+ @Input
+ Map<String, String> map;
+ @Input
+ Enumeration enumeration;
public CConfig() {
map = new HashMap<String, String>();
@@ -282,14 +429,14 @@ public class TestConfigUtils extends TestCase {
@ConfigClass
public static class DConfig {
- @Input int value;
+ @Input
+ int value;
}
public static class ConfigWithoutAnnotation {
}
enum Enumeration {
- X,
- Y,
+ X, Y,
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
index c0644e7..0e66400 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.assertEquals;
@@ -36,7 +37,7 @@ public class TestMAccountableEntity {
@Test
public void testInitialization() {
List<MConfig> configs = new ArrayList<MConfig>();
- MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
+ MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
MConfig config = new MConfig("CONFIGNAME", list);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMBooleanInput.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMBooleanInput.java b/common/src/test/java/org/apache/sqoop/model/TestMBooleanInput.java
index 57d2da2..3e863fa 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMBooleanInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMBooleanInput.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.model;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.assertEquals;
@@ -34,7 +35,8 @@ public class TestMBooleanInput {
*/
@Test
public void testInitialization() {
- MBooleanInput input = new MBooleanInput("sqoopsqoop", true);
+ MBooleanInput input = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY);
assertEquals("sqoopsqoop", input.getName());
assertEquals(true, input.isSensitive());
assertEquals(MInputType.BOOLEAN, input.getType());
@@ -46,17 +48,19 @@ public class TestMBooleanInput {
@Test
public void testEquals() {
// Positive test
- MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
- MBooleanInput input2 = new MBooleanInput("sqoopsqoop", true);
+ MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY);
+ MBooleanInput input2 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY);
assertTrue(input1.equals(input2));
// Negative test
- MBooleanInput input3 = new MBooleanInput("sqoopsqoop", false);
- MBooleanInput input4 = new MBooleanInput("sqoopsqoop", true);
+ MBooleanInput input3 = new MBooleanInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY );
+ MBooleanInput input4 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY );
assertFalse(input3.equals(input4));
- MBooleanInput input5 = new MBooleanInput("sqoopsqoop", false);
- MBooleanInput input6 = new MBooleanInput("sqoop", false);
+ MBooleanInput input5 = new MBooleanInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY );
+ MBooleanInput input6 = new MBooleanInput("sqoop", false, InputEditable.ANY, StringUtils.EMPTY );
assertFalse(input5.equals(input6));
}
@@ -65,7 +69,7 @@ public class TestMBooleanInput {
*/
@Test
public void testValue() {
- MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
+ MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY );
input1.setValue(true);
assertEquals(true, input1.getValue().booleanValue());
input1.setEmpty();
@@ -77,7 +81,7 @@ public class TestMBooleanInput {
*/
@Test
public void testUrlSafe() {
- MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
+ MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY );
input1.setValue(true);
// Getting URL safe string
String tmp = input1.getUrlSafeValueString();
@@ -91,7 +95,8 @@ public class TestMBooleanInput {
*/
@Test
public void testNamedElement() {
- MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
+ MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY);
assertEquals("sqoopsqoop.label", input1.getLabelKey());
assertEquals("sqoopsqoop.help", input1.getHelpKey());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConfig.java b/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
index 908348d..665b64a 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
@@ -20,6 +20,7 @@ package org.apache.sqoop.model;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
@@ -31,8 +32,8 @@ public class TestMConfig {
*/
@Test
public void testInitialization() {
- MInput<String> input1 = new MStringInput("sqoopsqoop1", true, (short) 5);
- MInput<String> input2 = new MStringInput("sqoopsqoop2", true, (short) 5);
+ MInput<String> input1 = new MStringInput("sqoopsqoop1", true, InputEditable.ANY, StringUtils.EMPTY , (short) 5);
+ MInput<String> input2 = new MStringInput("sqoopsqoop2", true, InputEditable.ANY, StringUtils.EMPTY , (short) 5);
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input1);
@@ -48,15 +49,15 @@ public class TestMConfig {
*/
@Test
public void testEquals() {
- MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1", false);
- MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2", false);
+ MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY );
+ MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2", false, InputEditable.ANY, StringUtils.EMPTY );
List<MInput<?>> list1 = new ArrayList<MInput<?>>();
list1.add(input1);
list1.add(input2);
MConfig mform1 = new MConfig("config", list1);
- MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false);
- MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false);
+ MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY );
+ MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false, InputEditable.ANY, StringUtils.EMPTY );
List<MInput<?>> list2 = new ArrayList<MInput<?>>();
list2.add(input3);
list2.add(input4);
@@ -66,10 +67,12 @@ public class TestMConfig {
@Test
public void testGetInputs() {
- MIntegerInput intInput = new MIntegerInput("Config.A", false);
- MMapInput mapInput = new MMapInput("Config.B", false);
- MStringInput stringInput = new MStringInput("Config.C", false, (short)3);
- MEnumInput enumInput = new MEnumInput("Config.D", false, new String[] {"I", "V"});
+ MIntegerInput intInput = new MIntegerInput("Config.A", false, InputEditable.ANY, StringUtils.EMPTY );
+ MMapInput mapInput = new MMapInput("Config.B", false, InputEditable.ANY, StringUtils.EMPTY );
+ MStringInput stringInput = new MStringInput("Config.C", false, InputEditable.ANY,
+ StringUtils.EMPTY, (short) 3);
+ MEnumInput enumInput = new MEnumInput("Config.D", false, InputEditable.ANY, StringUtils.EMPTY,
+ new String[] { "I", "V" });
List<MInput<?>> inputs = new ArrayList<MInput<?>>();
inputs.add(intInput);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java b/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java
index 4f8261c..6550dde 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.model;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import java.util.ArrayList;
@@ -30,16 +31,18 @@ public class TestMConfigList {
public void testGetInputs() {
List<MConfig> configs = new LinkedList<MConfig>();
- MIntegerInput intInput = new MIntegerInput("Config1.A", false);
- MMapInput mapInput = new MMapInput("Config1.B", false);
+ MIntegerInput intInput = new MIntegerInput("Config1.A", false, InputEditable.ANY, StringUtils.EMPTY);
+ MMapInput mapInput = new MMapInput("Config1.B", false, InputEditable.ANY, StringUtils.EMPTY);
List<MInput<?>> inputs = new ArrayList<MInput<?>>();
inputs.add(intInput);
inputs.add(mapInput);
configs.add(new MConfig("Config1", inputs));
- MStringInput stringInput = new MStringInput("Config2.C", false, (short)3);
- MEnumInput enumInput = new MEnumInput("Config2.D", false, new String[] {"I", "V"});
+ MStringInput stringInput = new MStringInput("Config2.C", false, InputEditable.ANY,
+ StringUtils.EMPTY, (short) 3);
+ MEnumInput enumInput = new MEnumInput("Config2.D", false, InputEditable.ANY, StringUtils.EMPTY,
+ new String[] { "I", "V" });
inputs = new ArrayList<MInput<?>>();
inputs.add(stringInput);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConnector.java b/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
index e1c02aa..cefa9f2 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
import org.apache.sqoop.common.Direction;
import org.testng.annotations.Test;
@@ -35,9 +36,9 @@ public class TestMConnector {
private MConnector createConnector(List<Direction> supportedDirections) {
List<MConfig> configs = new ArrayList<MConfig>();
- MIntegerInput inputs = new MIntegerInput("INTEGER-INPUT", false);
+ MIntegerInput inputs = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
inputs.setValue(100);
- MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
+ MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20);
strInput.setValue("TEST-VALUE");
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(inputs);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java b/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
index 39f09ce..744ac50 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.model;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.*;
@@ -33,18 +34,19 @@ public class TestMEnumInput {
@Test
public void testInitialization() {
String[] values = { "value1", "value2" };
- MEnumInput input = new MEnumInput("NAME", false, values);
+ MEnumInput input = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values);
assertEquals("NAME", input.getName());
assertArrayEquals(values, input.getValues());
assertEquals(MInputType.ENUM, input.getType());
- MEnumInput input1 = new MEnumInput("NAME", false, values);
+ MEnumInput input1 = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values);
assertEquals(input1, input);
String[] testVal = { "val", "test" };
- MEnumInput input2 = new MEnumInput("NAME1", false, testVal);
+ MEnumInput input2 = new MEnumInput("NAME1", false, InputEditable.ANY, StringUtils.EMPTY,
+ testVal);
assertFalse(input1.equals(input2));
- MEnumInput input3 = new MEnumInput("NAME", false, values);
+ MEnumInput input3 = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values);
input3.setValue(Enumeration.value1);
assertEquals("value1", input3.getValue());
}
@@ -55,8 +57,8 @@ public class TestMEnumInput {
@Test
public void testSensitivity() {
String[] values = { "value1", "value2" };
- MEnumInput input1 = new MEnumInput("NAME", false, values);
- MEnumInput input2 = new MEnumInput("NAME", true, values);
+ MEnumInput input1 = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values);
+ MEnumInput input2 = new MEnumInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY, values);
assertFalse(input1.isSensitive());
assertTrue(input2.isSensitive());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java b/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
index 69e511f..2c3decf 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.model;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.assertEquals;
@@ -33,7 +34,7 @@ public class TestMIntegerInput {
*/
@Test
public void testInitialization() {
- MIntegerInput input = new MIntegerInput("sqoopsqoop", false);
+ MIntegerInput input = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
assertEquals("sqoopsqoop", input.getName());
assertEquals(MInputType.INTEGER, input.getType());
}
@@ -44,13 +45,13 @@ public class TestMIntegerInput {
@Test
public void testEquals() {
// Positive test
- MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
- MIntegerInput input2 = new MIntegerInput("sqoopsqoop", false);
+ MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
+ MIntegerInput input2 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
assertTrue(input1.equals(input2));
// Negative test
- MIntegerInput input3 = new MIntegerInput("sqoopsqoop", false);
- MIntegerInput input4 = new MIntegerInput("sqoopsqoop1", false);
+ MIntegerInput input3 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
+ MIntegerInput input4 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY);
assertFalse(input3.equals(input4));
}
@@ -59,7 +60,7 @@ public class TestMIntegerInput {
*/
@Test
public void testValue() {
- MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
+ MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
input1.setValue(99);
assertEquals(new Integer(99), input1.getValue());
input1.setEmpty();
@@ -71,7 +72,7 @@ public class TestMIntegerInput {
*/
@Test
public void testUrlSafe() {
- MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
+ MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
input1.setValue(1001);
// Getting URL safe string
String tmp = input1.getUrlSafeValueString();
@@ -85,7 +86,7 @@ public class TestMIntegerInput {
*/
@Test
public void testNamedElement() {
- MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.CONNECTOR_ONLY, StringUtils.EMPTY, (short) 5);
assertEquals("sqoopsqoop.label", input1.getLabelKey());
assertEquals("sqoopsqoop.help", input1.getHelpKey());
}
@@ -95,8 +96,8 @@ public class TestMIntegerInput {
*/
@Test
public void testSensitivity() {
- MIntegerInput input1 = new MIntegerInput("NAME", false);
- MIntegerInput input2 = new MIntegerInput("NAME", true);
+ MIntegerInput input1 = new MIntegerInput("NAME", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
+ MIntegerInput input2 = new MIntegerInput("NAME", true, InputEditable.CONNECTOR_ONLY, StringUtils.EMPTY);
assertFalse(input1.isSensitive());
assertTrue(input2.isSensitive());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMJob.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMJob.java b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
index 605f429..ee8f45f 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMJob.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertNull;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
import org.apache.sqoop.common.Direction;
import org.testng.annotations.Test;
@@ -104,9 +105,9 @@ public class TestMJob {
private MFromConfig fromConfig() {
List<MConfig> configs = new ArrayList<MConfig>();
- MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
+ MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
input.setValue(100);
- MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
+ MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20);
strInput.setValue("TEST-VALUE");
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
@@ -118,7 +119,7 @@ public class TestMJob {
private MToConfig toConfig() {
List<MConfig> configs = new ArrayList<MConfig>();
- MMapInput input = new MMapInput("MAP-INPUT", false);
+ MMapInput input = new MMapInput("MAP-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
MConfig config = new MConfig("CONFIGTONAME", list);
@@ -128,7 +129,7 @@ public class TestMJob {
private MDriverConfig driverConfig() {
List<MConfig> configs = new ArrayList<MConfig>();
- MMapInput input = new MMapInput("MAP-INPUT", false);
+ MMapInput input = new MMapInput("MAP-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
MConfig config = new MConfig("CONFIGDRIVERNAME", list);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMLink.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMLink.java b/common/src/test/java/org/apache/sqoop/model/TestMLink.java
index e985c17..f22719f 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMLink.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMLink.java
@@ -20,6 +20,7 @@ package org.apache.sqoop.model;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
@@ -81,9 +82,9 @@ public class TestMLink {
private MLinkConfig linkConfig() {
List<MConfig> configs = new ArrayList<MConfig>();
- MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
+ MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
input.setValue(100);
- MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
+ MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20);
strInput.setValue("TEST-VALUE");
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java b/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
index c9b786b..53a3549 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
@@ -20,6 +20,7 @@ package org.apache.sqoop.model;
import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.assertEquals;
@@ -37,7 +38,7 @@ public class TestMMapInput {
*/
@Test
public void testInitialization() {
- MMapInput input = new MMapInput("sqoopsqoop", false);
+ MMapInput input = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
assertEquals("sqoopsqoop", input.getName());
assertEquals(MInputType.MAP, input.getType());
}
@@ -48,13 +49,13 @@ public class TestMMapInput {
@Test
public void testEquals() {
// Positive test
- MMapInput input1 = new MMapInput("sqoopsqoop", false);
- MMapInput input2 = new MMapInput("sqoopsqoop", false);
+ MMapInput input1 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
+ MMapInput input2 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
assertTrue(input1.equals(input2));
// Negative test
- MMapInput input3 = new MMapInput("sqoopsqoop", false);
- MMapInput input4 = new MMapInput("sqoopsqoop1", false);
+ MMapInput input3 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
+ MMapInput input4 = new MMapInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY);
assertFalse(input3.equals(input4));
}
@@ -63,7 +64,7 @@ public class TestMMapInput {
*/
@Test
public void testValue() {
- MMapInput input1 = new MMapInput("sqoopsqoop", false);
+ MMapInput input1 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
Map<String, String> map1 = new HashMap<String, String>();
input1.setValue(map1);
assertEquals(map1, input1.getValue());
@@ -76,7 +77,7 @@ public class TestMMapInput {
*/
@Test
public void testUrlSafe() {
- MMapInput input1 = new MMapInput("sqoopsqoop", false);
+ MMapInput input1 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
Map<String, String> map1 = new HashMap<String, String>();
input1.setValue(map1);
// Getting URL safe string
@@ -97,7 +98,7 @@ public class TestMMapInput {
*/
@Test
public void testNamedElement() {
- MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY, (short) 5);
assertEquals("sqoopsqoop.label", input1.getLabelKey());
assertEquals("sqoopsqoop.help", input1.getHelpKey());
}
@@ -107,8 +108,8 @@ public class TestMMapInput {
*/
@Test
public void testSensitivity() {
- MMapInput input1 = new MMapInput("NAME", false);
- MMapInput input2 = new MMapInput("NAME", true);
+ MMapInput input1 = new MMapInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY );
+ MMapInput input2 = new MMapInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY );
assertFalse(input1.isSensitive());
assertTrue(input2.isSensitive());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java b/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
index f851cbd..c523d65 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.model;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
@@ -31,7 +32,7 @@ public class TestMNamedElement {
*/
@Test
public void testInitialization() {
- MNamedElement named = new MIntegerInput("SQOOP", false);
+ MNamedElement named = new MIntegerInput("SQOOP", false, InputEditable.ANY, StringUtils.EMPTY);
assertEquals("SQOOP", named.getName());
assertEquals("SQOOP.label", named.getLabelKey());
assertEquals("SQOOP.help", named.getHelpKey());
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java b/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
index a4faf95..37a04c2 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.model;
+import org.apache.commons.lang.StringUtils;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
@@ -32,7 +33,8 @@ public class TestMStringInput {
@Test
public void testInitialization() {
short len = 6;
- MStringInput input = new MStringInput("sqoopsqoop", true, len);
+ MStringInput input = new MStringInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY,
+ len);
assertEquals("sqoopsqoop", input.getName());
assertEquals(true, input.isSensitive());
assertEquals(len, input.getMaxLength());
@@ -46,13 +48,17 @@ public class TestMStringInput {
public void testEquals() {
short len = 6;
// Positive test
- MStringInput input1 = new MStringInput("sqoopsqoop", true, len);
- MStringInput input2 = new MStringInput("sqoopsqoop", true, len);
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY, len);
+ MStringInput input2 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY, len);
assertTrue(input1.equals(input2));
// Negative test
- MStringInput input3 = new MStringInput("sqoopsqoop", false, len);
- MStringInput input4 = new MStringInput("sqoopsqoop", true, len);
+ MStringInput input3 = new MStringInput("sqoopsqoop", false, InputEditable.ANY,
+ StringUtils.EMPTY, len);
+ MStringInput input4 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY, len);
assertFalse(input3.equals(input4));
}
@@ -61,7 +67,8 @@ public class TestMStringInput {
*/
@Test
public void testValue() {
- MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY, (short) 5);
input1.setValue("sqoop");
assertEquals("sqoop", input1.getValue());
input1.setEmpty();
@@ -73,7 +80,8 @@ public class TestMStringInput {
*/
@Test
public void testUrlSafe() {
- MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY, (short) 5);
String s = "Sqoop%$!@#&*()Sqoop";
input1.setValue(s);
// Getting URL safe string
@@ -88,7 +96,8 @@ public class TestMStringInput {
*/
@Test
public void testNamedElement() {
- MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
+ StringUtils.EMPTY, (short) 5);
assertEquals("sqoopsqoop.label", input1.getLabelKey());
assertEquals("sqoopsqoop.help", input1.getHelpKey());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/6fc50b08/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java b/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
index f0bdda4..6fee4b5 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.model;
+import org.apache.commons.lang.StringUtils;
import org.apache.sqoop.validation.Message;
import org.apache.sqoop.validation.Status;
import org.testng.annotations.Test;
@@ -33,7 +34,7 @@ public class TestMValidatedElement {
*/
@Test
public void testInitialization() {
- MValidatedElement input = new MIntegerInput("input", false);
+ MValidatedElement input = new MIntegerInput("input", false,InputEditable.ANY, StringUtils.EMPTY );
assertEquals("input", input.getName());
assertEquals(Status.OK, input.getValidationStatus());
}
@@ -43,7 +44,7 @@ public class TestMValidatedElement {
*/
@Test
public void testVarious() {
- MValidatedElement input = new MIntegerInput("input", false);
+ MValidatedElement input = new MIntegerInput("input", false, InputEditable.ANY, StringUtils.EMPTY );
// Default status
assertEquals(Status.OK, input.getValidationStatus());