sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cheol...@apache.org
Subject git commit: SQOOP-919: Improve Form API for simple java handling
Date Mon, 11 Mar 2013 05:58:03 GMT
Updated Branches:
  refs/heads/sqoop2 2f9a2a71a -> 0cc834928


SQOOP-919: Improve Form API for simple java handling

(Jarcec Cecho via Cheolsoo Park)


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

Branch: refs/heads/sqoop2
Commit: 0cc834928a5a9f8dac516208715809a9113b5848
Parents: 2f9a2a7
Author: Cheolsoo Park <cheolsoo@apache.org>
Authored: Sun Mar 10 22:57:20 2013 -0700
Committer: Cheolsoo Park <cheolsoo@apache.org>
Committed: Sun Mar 10 22:57:20 2013 -0700

----------------------------------------------------------------------
 .../java/org/apache/sqoop/model/MConnection.java   |    8 +
 .../org/apache/sqoop/model/MConnectionForms.java   |   31 +---
 .../java/org/apache/sqoop/model/MEnumInput.java    |    6 +-
 .../main/java/org/apache/sqoop/model/MForm.java    |   28 +++
 .../java/org/apache/sqoop/model/MFormList.java     |  104 +++++++++++
 .../java/org/apache/sqoop/model/MJobForms.java     |   19 +--
 .../java/org/apache/sqoop/model/ModelError.java    |    4 +
 .../org/apache/sqoop/utils/ClassUtils.java.orig    |  141 ---------------
 .../org/apache/sqoop/model/TestMConnection.java    |    2 +
 .../org/apache/sqoop/model/TestMEnumInput.java     |    6 +
 .../java/org/apache/sqoop/model/TestMForm.java     |   20 ++
 .../java/org/apache/sqoop/model/TestMFormList.java |   57 ++++++
 .../connector/jdbc/generic/TableImportTest.java    |   25 ++--
 13 files changed, 258 insertions(+), 193 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/common/src/main/java/org/apache/sqoop/model/MConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConnection.java b/common/src/main/java/org/apache/sqoop/model/MConnection.java
index bc730bb..36dca42 100644
--- a/common/src/main/java/org/apache/sqoop/model/MConnection.java
+++ b/common/src/main/java/org/apache/sqoop/model/MConnection.java
@@ -64,4 +64,12 @@ public class MConnection extends MAccountableEntity {
   public MConnectionForms getFrameworkPart() {
     return frameworkPart;
   }
+
+  public MForm getConnectorForm(String formName) {
+    return connectorPart.getForm(formName);
+  }
+
+  public MForm getFrameworkForm(String formName) {
+    return frameworkPart.getForm(formName);
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java b/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
index 45e4666..d289a02 100644
--- a/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
+++ b/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
@@ -24,22 +24,16 @@ import java.util.List;
  * object for one part. Both connector and framework need to supply this object
  * to build up entire connection.
  */
-public class MConnectionForms {
-
-  private final List<MForm> forms;
+public class MConnectionForms extends MFormList {
 
   public MConnectionForms(List<MForm> forms) {
-    this.forms = forms;
-  }
-
-  public List<MForm> getForms() {
-    return forms;
+    super(forms);
   }
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder("connection, forms:");
-    sb.append(forms);
+    StringBuilder sb = new StringBuilder("Connection: ");
+    sb.append(super.toString());
     return sb.toString();
   }
 
@@ -49,21 +43,6 @@ public class MConnectionForms {
       return true;
     }
 
-    if (!(other instanceof MConnectionForms)) {
-      return false;
-    }
-
-    MConnectionForms mc = (MConnectionForms) other;
-    return forms.equals(mc.forms);
-  }
-
-  @Override
-  public int hashCode() {
-    int result = super.hashCode();
-    for(MForm form : forms) {
-      result = 31 * result + form.hashCode();
-    }
-
-    return result;
+    return super.equals(other);
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/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 bed2b04..77598a8 100644
--- a/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
@@ -62,6 +62,10 @@ public class MEnumInput extends MInput<String> {
       "Invalid value " + value);
   }
 
+  public void setValue(Enum value) {
+    setValue(value.toString());
+  }
+
   @Override
   public String getUrlSafeValueString() {
     return getValue();
@@ -118,6 +122,6 @@ public class MEnumInput extends MInput<String> {
 
   @Override
   public void setEmpty() {
-    setValue(null);
+    setValue((String)null);
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/common/src/main/java/org/apache/sqoop/model/MForm.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MForm.java b/common/src/main/java/org/apache/sqoop/model/MForm.java
index a55fe65..76998dd 100644
--- a/common/src/main/java/org/apache/sqoop/model/MForm.java
+++ b/common/src/main/java/org/apache/sqoop/model/MForm.java
@@ -17,6 +17,8 @@
  */
 package org.apache.sqoop.model;
 
+import org.apache.sqoop.common.SqoopException;
+
 import java.util.List;
 
 /**
@@ -38,6 +40,32 @@ public final class MForm extends MValidatedElement {
     return inputs;
   }
 
+  public MInput<?> getInput(String inputName) {
+    for(MInput<?> input: inputs) {
+      if(inputName.equals(input.getName())) {
+        return input;
+      }
+    }
+
+    throw new SqoopException(ModelError.MODEL_011, "Input name: " + inputName);
+  }
+
+  public MStringInput getStringInput(String inputName) {
+    return (MStringInput)getInput(inputName);
+  }
+
+  public MEnumInput getEnumInput(String inputName) {
+    return (MEnumInput)getInput(inputName);
+  }
+
+  public MIntegerInput getIntegerInput(String inputName) {
+    return (MIntegerInput)getInput(inputName);
+  }
+
+  public MMapInput getMapInput(String inputName) {
+    return (MMapInput)getInput(inputName);
+  }
+
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("form-").append(getName());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/common/src/main/java/org/apache/sqoop/model/MFormList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MFormList.java b/common/src/main/java/org/apache/sqoop/model/MFormList.java
new file mode 100644
index 0000000..3bf508d
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MFormList.java
@@ -0,0 +1,104 @@
+/**
+ * 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;
+
+import org.apache.sqoop.common.SqoopException;
+
+import java.util.List;
+
+/**
+ * Arbitrary list of forms.
+ */
+public class MFormList {
+
+  private final List<MForm> forms;
+
+  public MFormList(List<MForm> forms) {
+    this.forms = forms;
+  }
+
+  public List<MForm> getForms() {
+    return forms;
+  }
+
+  public MForm getForm(String formName) {
+    for(MForm form: forms) {
+      if(formName.equals(form.getName())) {
+        return form;
+      }
+    }
+
+    throw new SqoopException(ModelError.MODEL_010, "Form name: " + formName);
+  }
+
+  public MInput getInput(String name) {
+    String []parts = name.split("\\.");
+    if(parts.length != 2) {
+      throw new SqoopException(ModelError.MODEL_009, name);
+    }
+
+    return getForm(parts[0]).getInput(name);
+  }
+
+  public MStringInput getStringInput(String name) {
+    return (MStringInput)getInput(name);
+  }
+
+  public MEnumInput getEnumInput(String name) {
+    return (MEnumInput)getInput(name);
+  }
+
+  public MIntegerInput getIntegerInput(String name) {
+    return (MIntegerInput)getInput(name);
+  }
+
+  public MMapInput getMapInput(String name) {
+    return (MMapInput)getInput(name);
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (!(o instanceof MFormList)) return false;
+
+    MFormList mFormList = (MFormList) o;
+
+    if (!forms.equals(mFormList.forms)) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = super.hashCode();
+    for(MForm form : forms) {
+      result = 31 * result + form.hashCode();
+    }
+
+    return result;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("Forms: ");
+    for(MForm form : forms) {
+      sb.append(form.toString());
+    }
+    return sb.toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/common/src/main/java/org/apache/sqoop/model/MJobForms.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MJobForms.java b/common/src/main/java/org/apache/sqoop/model/MJobForms.java
index 0945a6a..bce646f 100644
--- a/common/src/main/java/org/apache/sqoop/model/MJobForms.java
+++ b/common/src/main/java/org/apache/sqoop/model/MJobForms.java
@@ -24,20 +24,19 @@ import java.util.List;
  * object for one part. Both connector and framework need to supply this object
  * to build up entire job.
  */
-public class MJobForms {
+public class MJobForms extends MFormList {
 
   private final MJob.Type type;
-  private final List<MForm> forms;
 
   public MJobForms(MJob.Type type, List<MForm> forms) {
+    super(forms);
     this.type = type;
-    this.forms = forms;
   }
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder("job type:").append(type.name());
-    sb.append(", forms: ").append(forms);
+    StringBuilder sb = new StringBuilder("Job type: ").append(type.name());
+    sb.append(super.toString());
     return sb.toString();
   }
 
@@ -45,10 +44,6 @@ public class MJobForms {
     return type;
   }
 
-  public List<MForm> getForms() {
-    return forms;
-  }
-
   @Override
   public boolean equals(Object other) {
     if (other == this) {
@@ -60,17 +55,13 @@ public class MJobForms {
     }
 
     MJobForms mj = (MJobForms) other;
-    return type.equals(mj.type) && forms.equals(mj.forms);
+    return type.equals(mj.type) && super.equals(mj);
   }
 
   @Override
   public int hashCode() {
     int result = super.hashCode();
     result = 31 * result + type.hashCode();
-    for(MForm form : forms) {
-      result = 31 * result + form.hashCode();
-    }
-
     return result;
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/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 f8d61ef..1f466fe 100644
--- a/common/src/main/java/org/apache/sqoop/model/ModelError.java
+++ b/common/src/main/java/org/apache/sqoop/model/ModelError.java
@@ -42,6 +42,10 @@ public enum ModelError implements ErrorCode {
 
   MODEL_009("Invalid input name"),
 
+  MODEL_010("Form do not exist"),
+
+  MODEL_011("Input do not exist"),
+
   ;
 
   private final String message;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/common/src/main/java/org/apache/sqoop/utils/ClassUtils.java.orig
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/utils/ClassUtils.java.orig b/common/src/main/java/org/apache/sqoop/utils/ClassUtils.java.orig
deleted file mode 100644
index b63fce2..0000000
--- a/common/src/main/java/org/apache/sqoop/utils/ClassUtils.java.orig
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * 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.utils;
-
-import org.apache.log4j.Logger;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-public final class ClassUtils {
-
-  private static final Logger LOG = Logger.getLogger(ClassUtils.class);
-
-  /**
-   * Load class by given name and return corresponding Class object.
-   *
-   * This method will return null in case that the class is not found, no
-   * exception will be rised.
-   *
-   * @param className Name of class
-   * @return Class instance or NULL
-   */
-  public static Class<?> loadClass(String className) {
-    if(className == null) {
-      return null;
-    }
-
-    Class<?> klass = null;
-    try {
-      klass = Class.forName(className);
-    } catch (ClassNotFoundException ex) {
-      LOG.debug("Exception while loading class: " + className, ex);
-    }
-
-    if (klass == null) {
-      // Try the context class loader if one exists
-      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
-      if (ctxLoader != null) {
-        try {
-          klass = ctxLoader.loadClass(className);
-        } catch (ClassNotFoundException ex) {
-          LOG.debug("Exception while load class: " + className, ex);
-        }
-      }
-    }
-
-    return klass;
-  }
-
-  /**
-   * Create instance of given class and given parameters.
-   *
-   * Please note that due to inherited limitations from Java languge, this
-   * method can't handle primitive types and NULL values.
-   *
-   * @param className Class name
-   * @param args Objects that should be passed as constructor arguments.
-   * @return Instance of new class or NULL in case of any error
-   */
-  public static Object instantiate(String className, Object ... args) {
-    return instantiate(loadClass(className), args);
-  }
-
-  /**
-   * Create instance of given class and given parameters.
-   *
-   * Please note that due to inherited limitations from Java languge, this
-   * method can't handle primitive types and NULL values.
-   *
-   * @param klass Class object
-   * @param args Objects that should be passed as constructor arguments.
-   * @return Instance of new class or NULL in case of any error
-   */
-  public static Object instantiate(Class klass, Object ... args) {
-    if(klass == null) {
-      return null;
-    }
-
-    Class []argumentTypes = new Class[args.length];
-    for(int i = 0; i < args.length; i++) {
-      Class type = args[i].getClass();
-       argumentTypes[i] = type;
-    }
-
-    try {
-      Constructor constructor = klass.getConstructor(argumentTypes);
-      return constructor.newInstance(args);
-    } catch (NoSuchMethodException e) {
-      LOG.error("Can't find such constructor.", e);
-    } catch (InvocationTargetException e) {
-      LOG.error("Can't instantiate object.", e);
-    } catch (InstantiationException e) {
-      LOG.error("Can't instantiate object.", e);
-    } catch (IllegalAccessException e) {
-      LOG.error("Can't instantiate object.", e);
-    }
-
-    return null;
-  }
-
-  /**
-   * Return jar path for given class.
-   *
-   * @param className Class name
-   * @return Path on local filesystem to jar where given jar is present
-   */
-  public static String jarForClass(String className) {
-    Class klass = loadClass(className);
-    return klass.getProtectionDomain().getCodeSource().getLocation().toString();
-  }
-
-
-  /**
-   * Return jar path for given class.
-   *
-   * @param klass Class object
-   * @return Path on local filesystem to jar where given jar is present
-   */
-  public static String jarForClass(Class klass) {
-    return klass.getProtectionDomain().getCodeSource().getLocation().toString();
-  }
-
-  private ClassUtils() {
-    // Disable explicit object creation
-  }
-}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConnection.java b/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
index d5f9f38..a99b7dc 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
@@ -43,6 +43,8 @@ public class TestMConnection {
     assertFalse(connector1().equals(connection.getFrameworkPart()));
     connection.setName("NAME");
     assertEquals("NAME", connection.getName());
+    assertEquals(connector1().getForms().get(0), connection.getConnectorForm("FORMNAME"));
+    assertEquals(connector2().getForms().get(0), connection.getFrameworkForm("form"));
   }
 
   private MConnectionForms connector1() {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/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 0a3392c..1d86c13 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
@@ -25,6 +25,8 @@ import org.junit.Test;
  * Test class for org.apache.sqoop.model.MEnumInput
  */
 public class TestMEnumInput {
+
+  public enum Enumeration { value1, value2}
   /**
    * Test for class initialization
    */
@@ -41,5 +43,9 @@ public class TestMEnumInput {
     String[] testVal = { "val", "test" };
     MEnumInput input2 = new MEnumInput("NAME1", testVal);
     assertFalse(input1.equals(input2));
+
+    MEnumInput input3 = new MEnumInput("NAME", values);
+    input3.setValue(Enumeration.value1);
+    assertEquals("value1", input3.getValue());
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/common/src/test/java/org/apache/sqoop/model/TestMForm.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMForm.java b/common/src/test/java/org/apache/sqoop/model/TestMForm.java
index 38443a7..b7b1356 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMForm.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMForm.java
@@ -65,4 +65,24 @@ public class TestMForm {
     MForm mform2 = new MForm("form", list2);
     assertEquals(mform2, mform1);
   }
+
+  @Test
+  public void testGetInputs() {
+    MIntegerInput intInput = new MIntegerInput("Form.A");
+    MMapInput mapInput = new MMapInput("Form.B");
+    MStringInput stringInput = new MStringInput("Form.C", false, (short)3);
+    MEnumInput enumInput = new MEnumInput("Form.D", new String[] {"I", "V"});
+
+    List<MInput<?>> inputs = new ArrayList<MInput<?>>();
+    inputs.add(intInput);
+    inputs.add(mapInput);
+    inputs.add(stringInput);
+    inputs.add(enumInput);
+
+    MForm form = new MForm("Form", inputs);
+    assertEquals(intInput, form.getIntegerInput("Form.A"));
+    assertEquals(mapInput, form.getMapInput("Form.B"));
+    assertEquals(stringInput, form.getStringInput("Form.C"));
+    assertEquals(enumInput, form.getEnumInput("Form.D"));
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMFormList.java b/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
new file mode 100644
index 0000000..5f599eb
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
@@ -0,0 +1,57 @@
+/**
+ * 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;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ *
+ */
+public class TestMFormList {
+  @Test
+  public void testGetInputs() {
+    List<MForm> forms = new LinkedList<MForm>();
+
+    MIntegerInput intInput = new MIntegerInput("Form1.A");
+    MMapInput mapInput = new MMapInput("Form1.B");
+
+    List<MInput<?>> inputs = new ArrayList<MInput<?>>();
+    inputs.add(intInput);
+    inputs.add(mapInput);
+    forms.add(new MForm("Form1", inputs));
+
+    MStringInput stringInput = new MStringInput("Form2.C", false, (short)3);
+    MEnumInput enumInput = new MEnumInput("Form2.D", new String[] {"I", "V"});
+
+    inputs = new ArrayList<MInput<?>>();
+    inputs.add(stringInput);
+    inputs.add(enumInput);
+    forms.add(new MForm("Form2", inputs));
+
+    MFormList form = new MFormList(forms);
+    assertEquals(intInput, form.getIntegerInput("Form1.A"));
+    assertEquals(mapInput, form.getMapInput("Form1.B"));
+    assertEquals(stringInput, form.getStringInput("Form2.C"));
+    assertEquals(enumInput, form.getEnumInput("Form2.D"));  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0cc83492/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableImportTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableImportTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableImportTest.java
index 538a277..05a799c 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableImportTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableImportTest.java
@@ -22,10 +22,9 @@ import org.apache.sqoop.framework.configuration.OutputFormat;
 import org.apache.sqoop.framework.configuration.StorageType;
 import org.apache.sqoop.integration.connector.ConnectorTestCase;
 import org.apache.sqoop.model.MConnection;
-import org.apache.sqoop.model.MEnumInput;
+import org.apache.sqoop.model.MFormList;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MPersistableEntity;
-import org.apache.sqoop.model.MStringInput;
 import org.apache.sqoop.model.MSubmission;
 import org.apache.sqoop.validation.Status;
 import org.junit.Test;
@@ -64,11 +63,13 @@ public class TableImportTest extends ConnectorTestCase {
     // Connection creation
     MConnection connection = getClient().newConnection(1L);
 
+    MFormList forms;
     // Connector values
-    ((MStringInput) (connection.getConnectorPart().getForms().get(0).getInputs().get(0))).setValue(provider.getJdbcDriver());
-    ((MStringInput) (connection.getConnectorPart().getForms().get(0).getInputs().get(1))).setValue(provider.getConnectionUrl());
-    ((MStringInput) (connection.getConnectorPart().getForms().get(0).getInputs().get(2))).setValue(provider.getConnectionUsername());
-    ((MStringInput) (connection.getConnectorPart().getForms().get(0).getInputs().get(3))).setValue(provider.getConnectionPassword());
+    forms = connection.getConnectorPart();
+    forms.getStringInput("connection.jdbcDriver").setValue(provider.getJdbcDriver());
+    forms.getStringInput("connection.connectionString").setValue(provider.getConnectionUrl());
+    forms.getStringInput("connection.username").setValue(provider.getConnectionUsername());
+    forms.getStringInput("connection.password").setValue(provider.getConnectionPassword());
     // Framework values
     // No need to set anything
 
@@ -79,12 +80,14 @@ public class TableImportTest extends ConnectorTestCase {
     MJob job = getClient().newJob(connection.getPersistenceId(), MJob.Type.IMPORT);
 
     // Connector values
-    ((MStringInput) (job.getConnectorPart().getForms().get(0).getInputs().get(0))).setValue(provider.escapeTableName(getTableName()));
-    ((MStringInput) (job.getConnectorPart().getForms().get(0).getInputs().get(3))).setValue(provider.escapeColumnName("id"));
+    forms = job.getConnectorPart();
+    forms.getStringInput("table.tableName").setValue(provider.escapeTableName(getTableName()));
+    forms.getStringInput("table.partitionColumn").setValue(provider.escapeColumnName("id"));
     // Framework values
-    ((MEnumInput) (job.getFrameworkPart().getForms().get(0).getInputs().get(0))).setValue(StorageType.HDFS.toString());
-    ((MEnumInput) (job.getFrameworkPart().getForms().get(0).getInputs().get(1))).setValue(OutputFormat.TEXT_FILE.toString());
-    ((MStringInput) (job.getFrameworkPart().getForms().get(0).getInputs().get(2))).setValue(getMapreduceDirectory());
+    forms = job.getFrameworkPart();
+    forms.getEnumInput("output.storageType").setValue(StorageType.HDFS);
+    forms.getEnumInput("output.outputFormat").setValue(OutputFormat.TEXT_FILE);
+    forms.getStringInput("output.outputDirectory").setValue(getMapreduceDirectory());
 
     assertEquals(Status.FINE, getClient().createJob(job));
     assertNotSame(MPersistableEntity.PERSISTANCE_ID_DEFAULT, job.getPersistenceId());


Mime
View raw message