You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ab...@apache.org on 2014/10/29 02:07:17 UTC

git commit: SQOOP-1629: Sqoop2: Add unique constraint on the Config table for name and type

Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 a203e7726 -> 31f30cc27


SQOOP-1629: Sqoop2: Add unique constraint on the Config table for name and type

(Veena Basavaraj via Abraham Elmahrek)


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

Branch: refs/heads/sqoop2
Commit: 31f30cc279471ebe3a2d02f913e98d82a0e4a239
Parents: a203e77
Author: Abraham Elmahrek <ab...@elmahrek.com>
Authored: Tue Oct 28 17:54:47 2014 -0700
Committer: Abraham Elmahrek <ab...@elmahrek.com>
Committed: Tue Oct 28 17:54:47 2014 -0700

----------------------------------------------------------------------
 .../derby/DerbyRepositoryHandler.java           |   5 +-
 .../repository/derby/DerbySchemaConstants.java  |   4 +
 .../derby/DerbySchemaUpgradeQuery.java          |  10 +-
 .../sqoop/repository/derby/DerbyTestCase.java   | 566 ++++++++++---------
 .../repository/derby/TestConnectorHandling.java |   4 +-
 .../sqoop/repository/derby/TestInputTypes.java  |  45 +-
 .../derby/TestRespositorySchemaUpgrade.java     |  49 +-
 7 files changed, 386 insertions(+), 297 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/31f30cc2/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
index 514b5ac..58d6a43 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
@@ -444,6 +444,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
       runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_UNIQUE_CONSTRAINT_NAME, conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_UNIQUE_CONSTRAINT_NAME, conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIGURABLE_ADD_UNIQUE_CONSTRAINT_NAME, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_ADD_UNIQUE_CONSTRAINT_NAME_TYPE_AND_CONFIGURABLE_ID, conn);
     }
 
     // last step upgrade the repository version to the latest value in the code
@@ -2743,7 +2744,9 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
                     + "; config: " + config
                     + "; index: " + configIndex
                     + "; expected: " + jobConfigs.size()
-            );
+                    + "; configIndex: " + configIndex
+
+                );
           }
 
           jobConfigs.add(config);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/31f30cc2/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
index f579b93..41ca107 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
@@ -140,6 +140,10 @@ public final class DerbySchemaConstants {
   public static final String CONSTRAINT_SQ_CFG_SQC_NAME = CONSTRAINT_PREFIX + "SQ_CFG_SQC";
   public static final String CONSTRAINT_SQ_CFG_SQC = SCHEMA_PREFIX + CONSTRAINT_SQ_CFG_SQC_NAME;
 
+  // unique name constraint
+  public static final String CONSTRAINT_SQ_CONFIG_UNIQUE_NAME_TYPE_CONFIGURABLE = CONSTRAINT_PREFIX + "SQ_CFG_NAME_TYPE_CONFIGURABLE_UNIQUE";
+  public static final String CONSTRAINT_SQ_CONFIG_UNIQUE = SCHEMA_PREFIX + CONSTRAINT_SQ_CONFIG_UNIQUE_NAME_TYPE_CONFIGURABLE;
+
   // SQ_CONFIG_DIRECTIONS
 
   public static final String TABLE_SQ_CONFIG_DIRECTIONS_NAME = "SQ_CONFIG_DIRECTIONS";

http://git-wip-us.apache.org/repos/asf/sqoop/blob/31f30cc2/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
index 0bdb4c6..2abdfe5 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
@@ -421,13 +421,21 @@ public final class DerbySchemaUpgradeQuery {
   public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_DROP_COLUMN_SQ_CFG_DIRECTION_VARCHAR = "ALTER TABLE "
       + TABLE_SQ_CONFIG + " DROP COLUMN " + COLUMN_SQ_CFG_DIRECTION;
 
-  // add unique constraint on the configurable table
+  // add unique constraint on the configurable table for name
   public static final String QUERY_UPGRADE_TABLE_SQ_CONFIGURABLE_ADD_UNIQUE_CONSTRAINT_NAME = "ALTER TABLE "
       + TABLE_SQ_CONFIGURABLE
       + " ADD CONSTRAINT "
       + CONSTRAINT_SQ_CONFIGURABLE_UNIQUE
       + " UNIQUE (" + COLUMN_SQC_NAME + ")";
 
+  // add unique constraint on the config table for name and type and configurableId
+  public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_ADD_UNIQUE_CONSTRAINT_NAME_TYPE_AND_CONFIGURABLE_ID = "ALTER TABLE "
+      + TABLE_SQ_CONFIG
+      + " ADD CONSTRAINT "
+      + CONSTRAINT_SQ_CONFIG_UNIQUE
+      + " UNIQUE ("
+      + COLUMN_SQ_CFG_NAME + ", " + COLUMN_SQ_CFG_TYPE + ", " + COLUMN_SQ_CFG_CONFIGURABLE + ")";
+
   private DerbySchemaUpgradeQuery() {
     // Disable explicit object creation
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/31f30cc2/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
index 3398c91..8a1e346 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
@@ -57,11 +57,9 @@ import org.junit.Before;
  */
 abstract public class DerbyTestCase {
 
-  public static final String DERBY_DRIVER =
-    "org.apache.derby.jdbc.EmbeddedDriver";
+  public static final String DERBY_DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
 
-  public static final String JDBC_URL =
-    "jdbc:derby:memory:myDB";
+  public static final String JDBC_URL = "jdbc:derby:memory:myDB";
 
   private Connection connection;
 
@@ -75,7 +73,7 @@ abstract public class DerbyTestCase {
   @After
   public void tearDown() throws Exception {
     // Close active link
-    if(connection != null) {
+    if (connection != null) {
       connection.close();
     }
 
@@ -87,30 +85,6 @@ abstract public class DerbyTestCase {
     }
   }
 
-  private Map<String, List<Long>> getNameToIdListMap(PreparedStatement ps) throws SQLException {
-    Map<String, List<Long>> nameToIdListMap = new TreeMap<String, List<Long>>();
-    ResultSet rs = null;
-
-    try {
-      rs = ps.executeQuery();
-      while (rs.next()) {
-        if (!nameToIdListMap.containsKey(rs.getString(1))) {
-          nameToIdListMap.put(rs.getString(1), new LinkedList<Long>());
-        }
-        nameToIdListMap.get(rs.getString(1)).add(rs.getLong(2));
-      }
-    } finally {
-      if (rs != null) {
-        rs.close();
-      }
-      if (ps != null) {
-        ps.close();
-      }
-    }
-
-    return nameToIdListMap;
-  }
-
   void renameEntitiesForConnectionAndForm() throws Exception {
     // SQ_LINK schema upgrades
     // drop the constraint before rename and add it back later
@@ -237,12 +211,14 @@ abstract public class DerbyTestCase {
       renameConnectorToConfigurable();
       // add the name constraint for configurable
       runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIGURABLE_ADD_UNIQUE_CONSTRAINT_NAME);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_ADD_UNIQUE_CONSTRAINT_NAME_TYPE_AND_CONFIGURABLE_ID);
     }
 
     // deprecated repository version
-    runQuery("INSERT INTO SQOOP.SQ_SYSTEM(SQM_KEY, SQM_VALUE) VALUES('version', '"  + version + "')");
+    runQuery("INSERT INTO SQOOP.SQ_SYSTEM(SQM_KEY, SQM_VALUE) VALUES('version', '" + version + "')");
     // new repository version
-    runQuery("INSERT INTO SQOOP.SQ_SYSTEM(SQM_KEY, SQM_VALUE) VALUES('repository.version', '"  + version + "')");
+    runQuery("INSERT INTO SQOOP.SQ_SYSTEM(SQM_KEY, SQM_VALUE) VALUES('repository.version', '"
+        + version + "')");
 
   }
 
@@ -252,7 +228,6 @@ abstract public class DerbyTestCase {
 
   /**
    * Run arbitrary query on derby memory repository.
-   *
    * @param query Query to execute
    * @throws Exception
    */
@@ -263,9 +238,9 @@ abstract public class DerbyTestCase {
 
       for (int i = 0; i < args.length; ++i) {
         if (args[i] instanceof String) {
-          stmt.setString(i + 1, (String)args[i]);
+          stmt.setString(i + 1, (String) args[i]);
         } else if (args[i] instanceof Long) {
-          stmt.setLong(i + 1, (Long)args[i]);
+          stmt.setLong(i + 1, (Long) args[i]);
         } else {
           stmt.setString(i + 1, args[i].toString());
         }
@@ -289,13 +264,14 @@ abstract public class DerbyTestCase {
   protected Long runInsertQuery(String query, Object... args) throws Exception {
     PreparedStatement stmt = null;
     try {
-      stmt = getDerbyDatabaseConnection().prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
+      stmt = getDerbyDatabaseConnection().prepareStatement(query,
+          PreparedStatement.RETURN_GENERATED_KEYS);
 
       for (int i = 0; i < args.length; ++i) {
         if (args[i] instanceof String) {
-          stmt.setString(i + 1, (String)args[i]);
+          stmt.setString(i + 1, (String) args[i]);
         } else if (args[i] instanceof Long) {
-          stmt.setLong(i + 1, (Long)args[i]);
+          stmt.setLong(i + 1, (Long) args[i]);
         } else {
           stmt.setString(i + 1, args[i].toString());
         }
@@ -337,67 +313,57 @@ abstract public class DerbyTestCase {
         + "VALUES('A', 'org.apache.sqoop.test.A', '1.0-test')");
 
     String connector = "1";
-
+    int index = 0;
     // Connector config entries
-    for(String operation : new String[] {"null", "'IMPORT'", "'EXPORT'"}) {
+    for (String operation : new String[] { "null", "'IMPORT'", "'EXPORT'" }) {
 
       String type;
-      if(operation.equals("null")) {
+      if (operation.equals("null")) {
         type = "LINK";
       } else {
         type = "JOB";
       }
-
+      String configName = "C1" + type + index;
       runQuery("INSERT INTO SQOOP.SQ_FORM"
-          + "(SQF_CONNECTOR, SQF_OPERATION, SQF_NAME, SQF_TYPE, SQF_INDEX) "
-          + "VALUES("
-          + connector  + ", "
-          + operation
-          + ", 'C1', '"
-          + type
-          + "', 0)");
+          + "(SQF_CONNECTOR, SQF_OPERATION, SQF_NAME, SQF_TYPE, SQF_INDEX) " + "VALUES("
+          + connector + ", " + operation + ",'" + configName + "'," + "'" + type + "'," + " 0)");
+      configName = "C2" + type + index;
       runQuery("INSERT INTO SQOOP.SQ_FORM"
-          + "(SQF_CONNECTOR, SQF_OPERATION, SQF_NAME, SQF_TYPE, SQF_INDEX) "
-          + "VALUES("
-          + connector + ", "
-          + operation
-          +  ", 'C2', '"
-          + type
-          + "', 1)");
+          + "(SQF_CONNECTOR, SQF_OPERATION, SQF_NAME, SQF_TYPE, SQF_INDEX) " + "VALUES("
+          + connector + ", " + operation + ",'" + configName + "'," + "'" + type + "'," + " 1)");
+      index++;
     }
 
     // Driver config entries
     runQuery("INSERT INTO SQOOP.SQ_FORM"
         + "(SQF_CONNECTOR, SQF_OPERATION, SQF_NAME, SQF_TYPE, SQF_INDEX) VALUES"
-        + "(NULL, 'IMPORT', 'output', 'JOB', 0),"
-        + "(NULL, 'IMPORT', 'throttling', 'JOB', 1),"
-        + "(NULL, 'EXPORT', 'input', 'JOB', 0),"
-        + "(NULL, 'EXPORT', 'throttling', 'JOB', 1),"
+        + "(NULL, 'IMPORT', 'output', 'JOB', 0)," + "(NULL, 'IMPORT', 'throttling', 'JOB', 1),"
+        + "(NULL, 'EXPORT', 'input', 'JOB', 0)," + "(NULL, 'EXPORT', 'throttling', 'JOB', 1),"
         + "(NULL, NULL, 'security', 'LINK', 0)");
 
     // Connector input entries
-    for(int i = 0; i < 3; i++) {
+    for (int i = 0; i < 3; i++) {
       // First config
       runQuery("INSERT INTO SQOOP.SQ_INPUT"
-          +"(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+          + "(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
           + " VALUES('I1', " + (i * 2 + 1) + ", 0, 'STRING', false, 30)");
       runQuery("INSERT INTO SQOOP.SQ_INPUT"
-          +"(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+          + "(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
           + " VALUES('I2', " + (i * 2 + 1) + ", 1, 'MAP', false, 30)");
 
       // Second config
       runQuery("INSERT INTO SQOOP.SQ_INPUT"
-          +"(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+          + "(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
           + " VALUES('I3', " + (i * 2 + 2) + ", 0, 'STRING', false, 30)");
       runQuery("INSERT INTO SQOOP.SQ_INPUT"
-          +"(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+          + "(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
           + " VALUES('I4', " + (i * 2 + 2) + ", 1, 'MAP', false, 30)");
     }
 
     // Driver input entries.
     runQuery("INSERT INTO SQOOP.SQ_INPUT (SQI_NAME, SQI_FORM, SQI_INDEX,"
         + " SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH, SQI_ENUMVALS)"
-        +" VALUES ('security.maxConnections',11,0,'INTEGER','false',NULL,NULL),"
+        + " VALUES ('security.maxConnections',11,0,'INTEGER','false',NULL,NULL),"
         + "('input.inputDirectory',9,0,'STRING','false',255,NULL),"
         + "('throttling.extractors',8,0,'INTEGER','false',NULL,NULL),"
         + "('throttling.loaders',8,1,'INTEGER','false',NULL,NULL),"
@@ -409,20 +375,92 @@ abstract public class DerbyTestCase {
         + "('throttling.loaders',10,1,'INTEGER','false',NULL,NULL)");
   }
 
+  protected void addConnectorA() throws Exception {
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIGURABLE(SQC_NAME, SQC_CLASS, SQC_VERSION, SQC_TYPE)"
+        + "VALUES('A', 'org.apache.sqoop.test.A', '1.0-test', 'CONNECTOR')");
+
+    // insert 2 directions for connector A
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS(SQCD_CONNECTOR, SQCD_DIRECTION)"
+        + "VALUES(1, 1)");// FROM
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS(SQCD_CONNECTOR, SQCD_DIRECTION)"
+        + "VALUES(1, 2)");// TO
+
+    // insert the 2 link configs
+    // NOTE: link config has no direction
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'l1', 'LINK', 0)");// SQ_CFG_INDEX holds the ordering of
+                                        // the config for each type
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'l2', 'LINK', 1)");
+
+    // insert 2 FROM JOB configs
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'from1', 'JOB', 0)");
+    // insert the config direction for the from1-config
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG_DIRECTIONS"
+        + "(SQ_CFG_DIR_CONFIG, SQ_CFG_DIR_DIRECTION) " + "VALUES(3, 1)");
+
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'from2', 'JOB', 1)");
+    // insert the config direction for the from2-config
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG_DIRECTIONS"
+        + "(SQ_CFG_DIR_CONFIG, SQ_CFG_DIR_DIRECTION) " + "VALUES(4, 1)");
+
+    // insert 2 TO JOB configs
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'to1', 'JOB', 0)");
+    // insert the config direction for the to1-config
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG_DIRECTIONS"
+        + "(SQ_CFG_DIR_CONFIG, SQ_CFG_DIR_DIRECTION) " + "VALUES(5, 2)");
+
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'to2', 'JOB', 1)");
+    // insert the config direction for the to2-config
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG_DIRECTIONS"
+        + "(SQ_CFG_DIR_CONFIG, SQ_CFG_DIR_DIRECTION) " + "VALUES(6, 2)");
+
+    for (int i = 0; i < 3; i++) {
+      // First config
+      runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
+          + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+          + " VALUES('I1', " + (i * 2 + 1) + ", 0, 'STRING', false, 30)");
+      runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
+          + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+          + " VALUES('I2', " + (i * 2 + 1) + ", 1, 'MAP', false, 30)");
+
+      // Second config
+      runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
+          + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+          + " VALUES('I3', " + (i * 2 + 2) + ", 0, 'STRING', false, 30)");
+      runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
+          + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+          + " VALUES('I4', " + (i * 2 + 2) + ", 1, 'MAP', false, 30)");
+    }
+
+  }
+
   protected void loadConnectorAndDriverConfigVersion4() throws Exception {
     Long configId;
-    runQuery("INSERT INTO SQOOP.SQ_CONFIGURABLE(SQC_NAME, SQC_CLASS, SQC_VERSION, SQC_TYPE)"
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIGURABLE(SQC_NAME, SQC_CLASS, SQC_VERSION, SQC_TYPE)"
         + "VALUES('A', 'org.apache.sqoop.test.A', '1.0-test', 'CONNECTOR')");
 
     for (String connector : new String[] { "1" }) {
       // Directions
-      runQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS(SQCD_CONNECTOR, SQCD_DIRECTION)"
+      runInsertQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS(SQCD_CONNECTOR, SQCD_DIRECTION)"
           + "VALUES(" + connector + ", 1)");
-      runQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS(SQCD_CONNECTOR, SQCD_DIRECTION)"
+      runInsertQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS(SQCD_CONNECTOR, SQCD_DIRECTION)"
           + "VALUES(" + connector + ", 2)");
 
       // connector configs with connectorId as 1
-      for (String direction : new String[]{null, "1", "2"}) {
+      // all config names have to be unique per type
+      int index = 0;
+      for (String direction : new String[] { null, "1", "2" }) {
 
         String type;
         if (direction == null) {
@@ -430,41 +468,42 @@ abstract public class DerbyTestCase {
         } else {
           type = "JOB";
         }
-
+        String configName = "C1" + type + index;
         configId = runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
-            + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
-            + "VALUES(" + connector + ", 'C1', '" + type + "', 0)");
+            + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) " + "VALUES("
+            + connector + ", '" + configName + "', '" + type + "', 0)");
 
         if (direction != null) {
           runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG_DIRECTIONS"
-              + "(SQ_CFG_DIR_CONFIG, SQ_CFG_DIR_DIRECTION) "
-              + "VALUES(" + configId + ", " + direction + ")");
+              + "(SQ_CFG_DIR_CONFIG, SQ_CFG_DIR_DIRECTION) " + "VALUES(" + configId + ", "
+              + direction + ")");
         }
-
+        configName = "C2" + type + index;
         configId = runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
-            + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
-            + "VALUES(" + connector + ", 'C2', '" + type + "', 1)");
+            + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) " + "VALUES("
+            + connector + ", '" + configName + "', '" + type + "', 1)");
 
         if (direction != null) {
           runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG_DIRECTIONS"
-              + "(SQ_CFG_DIR_CONFIG, SQ_CFG_DIR_DIRECTION) "
-              + "VALUES(" + configId + ", " + direction + ")");
+              + "(SQ_CFG_DIR_CONFIG, SQ_CFG_DIR_DIRECTION) " + "VALUES(" + configId + ", "
+              + direction + ")");
         }
+        index++;
       }
     }
 
     // insert a driver
-    runQuery("INSERT INTO SQOOP.SQ_CONFIGURABLE(SQC_NAME, SQC_CLASS, SQC_VERSION, SQC_TYPE)"
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIGURABLE(SQC_NAME, SQC_CLASS, SQC_VERSION, SQC_TYPE)"
         + "VALUES('SqoopDriver', 'org.apache.sqoop.driver.Driver', '1.0-test', 'DRIVER')");
 
     // driver config with driverId as 2
-    for (String type : new String[]{"JOB"}) {
-      runQuery("INSERT INTO SQOOP.SQ_CONFIG"
-          + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
-          + "VALUES(2" + ", 'C1', '" + type + "', 0)");
-      runQuery("INSERT INTO SQOOP.SQ_CONFIG"
-          + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
-          + "VALUES(2" + ", 'C2', '" + type + "', 1)");
+    for (String type : new String[] { "JOB" }) {
+      runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+          + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) " + "VALUES(2"
+          + ", 'd1', '" + type + "', 0)");
+      runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+          + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) " + "VALUES(2"
+          + ", 'd2', '" + type + "', 1)");
     }
 
     // Input entries
@@ -473,44 +512,43 @@ abstract public class DerbyTestCase {
     // Connector job (TO) config: 8-11
     // Driver JOB config: 12-15
     for (int i = 0; i < 4; i++) {
-    // First config
-      runQuery("INSERT INTO SQOOP.SQ_INPUT"
+      // First config
+      runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
           + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
           + " VALUES('I1', " + (i * 2 + 1) + ", 0, 'STRING', false, 30)");
-      runQuery("INSERT INTO SQOOP.SQ_INPUT"
+      runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
           + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
           + " VALUES('I2', " + (i * 2 + 1) + ", 1, 'MAP', false, 30)");
 
       // Second config
-      runQuery("INSERT INTO SQOOP.SQ_INPUT"
+      runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
           + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
           + " VALUES('I3', " + (i * 2 + 2) + ", 0, 'STRING', false, 30)");
-      runQuery("INSERT INTO SQOOP.SQ_INPUT"
+      runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
           + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
           + " VALUES('I4', " + (i * 2 + 2) + ", 1, 'MAP', false, 30)");
     }
   }
 
-
-
   /**
    * Load testing connector and driver config into repository.
    *
-   * @param version system version (2 or 4)
+   * @param version
+   *          system version (2 or 4)
    * @throws Exception
    */
   protected void loadConnectorAndDriverConfig(int version) throws Exception {
-    switch(version) {
-      case 2:
-        loadConnectorAndDriverConfigVersion2();
-        break;
+    switch (version) {
+    case 2:
+      loadConnectorAndDriverConfigVersion2();
+      break;
 
-      case 4:
-        loadConnectorAndDriverConfigVersion4();
-        break;
+    case 4:
+      loadConnectorAndDriverConfigVersion4();
+      break;
 
-      default:
-        throw new AssertionError("Invalid connector and framework version: " + version);
+    default:
+      throw new AssertionError("Invalid connector and framework version: " + version);
     }
   }
 
@@ -519,8 +557,7 @@ abstract public class DerbyTestCase {
   }
 
   /**
-   * Load testing link objects into  repository.
-   *
+   * Load testing link objects into repository.
    * @param version system version (2 or 4)
    * @throws Exception
    */
@@ -528,38 +565,34 @@ abstract public class DerbyTestCase {
     switch (version) {
     case 2:
       // Insert two connections - CA and CB
-      runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) "
-          + "VALUES('CA', 1)");
-      runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) "
-          + "VALUES('CB', 1)");
+      runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) " + "VALUES('CA', 1)");
+      runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) " + "VALUES('CB', 1)");
 
-      for(String ci : new String[] {"1", "2"}) {
-        for(String i : new String[] {"1", "3", "13", "15"}) {
+      for (String ci : new String[] { "1", "2" }) {
+        for (String i : new String[] { "1", "3", "13", "15" }) {
           runQuery("INSERT INTO SQOOP.SQ_CONNECTION_INPUT"
-              + "(SQNI_CONNECTION, SQNI_INPUT, SQNI_VALUE) "
-              + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
+              + "(SQNI_CONNECTION, SQNI_INPUT, SQNI_VALUE) " + "VALUES(" + ci + ", " + i
+              + ", 'Value" + i + "')");
         }
       }
       break;
 
-      case 4:
-        // Insert two links - CA and CB
-        runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) "
-            + "VALUES('CA', 1)");
-        runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) "
-            + "VALUES('CB', 1)");
-
-        for (String ci : new String[]{"1", "2"}) {
-          for (String i : new String[]{"1", "3", "13", "15"}) {
-            runQuery("INSERT INTO SQOOP.SQ_LINK_INPUT"
-                + "(SQ_LNKI_LINK, SQ_LNKI_INPUT, SQ_LNKI_VALUE) "
-                + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
-          }
+    case 4:
+      // Insert two links - CA and CB
+      runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) " + "VALUES('CA', 1)");
+      runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) " + "VALUES('CB', 1)");
+
+      for (String ci : new String[] { "1", "2" }) {
+        for (String i : new String[] { "1", "3", "13", "15" }) {
+          runQuery("INSERT INTO SQOOP.SQ_LINK_INPUT"
+              + "(SQ_LNKI_LINK, SQ_LNKI_INPUT, SQ_LNKI_VALUE) " + "VALUES(" + ci + ", " + i
+              + ", 'Value" + i + "')");
         }
-        break;
+      }
+      break;
 
-      default:
-        throw new AssertionError("Invalid connector and framework version: " + version);
+    default:
+      throw new AssertionError("Invalid connector and framework version: " + version);
     }
   }
 
@@ -568,74 +601,65 @@ abstract public class DerbyTestCase {
   }
 
   /**
-   * Load testing job objects into  repository.
-   *
+   * Load testing job objects into repository.
    * @param version system version (2 or 4)
    * @throws Exception
    */
   public void loadJobs(int version) throws Exception {
     int index = 0;
     switch (version) {
-      case 2:
-        for(String type : new String[] {"IMPORT", "EXPORT"}) {
-          for(String name : new String[] {"JA", "JB"} ) {
-            runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_CONNECTION, SQB_TYPE)"
-                + " VALUES('" + type + "_" + name + "', 1, '" + type + "')");
-          }
+    case 2:
+      for (String type : new String[] { "IMPORT", "EXPORT" }) {
+        for (String name : new String[] { "JA", "JB" }) {
+          runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_CONNECTION, SQB_TYPE)" + " VALUES('"
+              + type + "_" + name + "', 1, '" + type + "')");
         }
+      }
 
-        // Import inputs
-        for(String ci : new String[] {"1", "2"}) {
-          for(String i : new String[] {"5", "7", "17", "19"}) {
-            runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT"
-                + "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
-                + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
-          }
+      // Import inputs
+      for (String ci : new String[] { "1", "2" }) {
+        for (String i : new String[] { "5", "7", "17", "19" }) {
+          runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT" + "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
+              + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
         }
+      }
 
-        // Export inputs
-        for(String ci : new String[] {"3", "4"}) {
-          for(String i : new String[] {"9", "11"}) {
-            runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT"
-                + "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
-                + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
-          }
+      // Export inputs
+      for (String ci : new String[] { "3", "4" }) {
+        for (String i : new String[] { "9", "11" }) {
+          runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT" + "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
+              + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
         }
-        break;
+      }
+      break;
 
+    case 4:
+      for (String name : new String[] { "JA", "JB", "JC", "JD" }) {
+        runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_FROM_LINK, SQB_TO_LINK)" + " VALUES('"
+            + name + index + "', 1, 1)");
+      }
 
-      case 4:
-        for (String name : new String[]{"JA", "JB", "JC", "JD"}) {
-          runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_FROM_LINK, SQB_TO_LINK)"
-              + " VALUES('" + name + index + "', 1, 1)");
+      // Odd IDs inputs have values
+      for (String ci : new String[] { "1", "2", "3", "4" }) {
+        for (String i : new String[] { "5", "9", "13" }) {
+          runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT" + "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
+              + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
         }
 
-        // Odd IDs inputs have values
-        for (String ci : new String[]{"1", "2", "3", "4"}) {
-          for (String i : new String[]{"5", "9", "13"}) {
-            runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT"
-                + "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
-                + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
-          }
-
-          for (String i : new String[]{"7", "11", "15"}) {
-            runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT"
-                + "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
-                + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
-          }
+        for (String i : new String[] { "7", "11", "15" }) {
+          runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT" + "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
+              + "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
         }
-        break;
+      }
+      break;
 
-      default:
-        throw new AssertionError("Invalid connector and framework version: " + version);
+    default:
+      throw new AssertionError("Invalid connector and framework version: " + version);
     }
   }
 
   /**
    * testing job with non unique name objects into repository.
-   *
-   * @param version
-   *          system version 4
    * @throws Exception
    */
   public void loadNonUniqueJobsInVersion4() throws Exception {
@@ -649,23 +673,18 @@ abstract public class DerbyTestCase {
 
   /**
    * testing link with non unique name objects into repository.
-   *
-   * @param version
-   *          system version 4
    * @throws Exception
    */
   public void loadNonUniqueLinksInVersion4() throws Exception {
 
     // Insert two links - CA and CA
-    runInsertQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) " + "VALUES('CA', 1)");
+    runInsertQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) "
+        + "VALUES('CA', 1)");
     runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) " + "VALUES('CA', 1)");
   }
 
   /**
    * testing configurable with non unique name objects into repository.
-   *
-   * @param version
-   *          system version 4
    * @throws Exception
    */
   public void loadNonUniqueConfigurablesInVersion4() throws Exception {
@@ -678,6 +697,48 @@ abstract public class DerbyTestCase {
 
   }
 
+  /**
+   * testing config with non unique nam/type objects into repository.
+   * @throws Exception
+   */
+  public void loadNonUniqueConfigNameTypeInVersion4() throws Exception {
+
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'C1', 'LINK', 0)");
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'C1', 'LINK', 0)");
+  }
+
+  /**
+   * testing config with non unique nam/type objects into repository.
+   * @throws Exception
+   */
+  public void loadNonUniqueConfigNameButUniqueTypeInVersion4() throws Exception {
+
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'C1', 'LINK', 0)");
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'C1', 'JOB', 0)");
+  }
+
+  /**
+   * testing config with non unique name/type objects into repository.
+   * @throws Exception
+   */
+  public void loadNonUniqueConfigNameAndTypeButUniqueConfigurableInVersion4() throws Exception {
+
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(1, 'C1', 'LINK', 0)");
+    runInsertQuery("INSERT INTO SQOOP.SQ_CONFIG"
+        + "(SQ_CFG_CONFIGURABLE, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+        + "VALUES(2, 'C1', 'LINK', 0)");
+  }
+
   public void loadJobsForLatestVersion() throws Exception {
     loadJobs(DerbyRepoConstants.LATEST_DERBY_REPOSITORY_VERSION);
   }
@@ -689,50 +750,37 @@ abstract public class DerbyTestCase {
     // Connector entry
     Long connectorId = runInsertQuery("INSERT INTO SQOOP.SQ_CONFIGURABLE(SQC_NAME, SQC_CLASS, SQC_VERSION, SQC_TYPE)"
         + "VALUES('B', 'org.apache.sqoop.test.B', '1.0-test', 'CONNECTOR')");
-    runQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS (SQCD_CONNECTOR, SQCD_DIRECTION) VALUES (" + connectorId + ", 1)");
-    runQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS (SQCD_CONNECTOR, SQCD_DIRECTION) VALUES (" + connectorId + ", 2)");
+    runQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS (SQCD_CONNECTOR, SQCD_DIRECTION) VALUES ("
+        + connectorId + ", 1)");
+    runQuery("INSERT INTO SQOOP.SQ_CONNECTOR_DIRECTIONS (SQCD_CONNECTOR, SQCD_DIRECTION) VALUES ("
+        + connectorId + ", 2)");
   }
 
   /**
    * Load testing submissions into the repository.
-   *
    * @throws Exception
    */
-  public void loadSubmissions() throws  Exception {
-    runQuery("INSERT INTO SQOOP.SQ_COUNTER_GROUP "
-      + "(SQG_NAME) "
-      + "VALUES"
-      + "('gA'), ('gB')"
-    );
-
-    runQuery("INSERT INTO SQOOP.SQ_COUNTER "
-      + "(SQR_NAME) "
-      + "VALUES"
-      + "('cA'), ('cB')"
-    );
+  public void loadSubmissions() throws Exception {
+    runQuery("INSERT INTO SQOOP.SQ_COUNTER_GROUP " + "(SQG_NAME) " + "VALUES" + "('gA'), ('gB')");
+
+    runQuery("INSERT INTO SQOOP.SQ_COUNTER " + "(SQR_NAME) " + "VALUES" + "('cA'), ('cB')");
 
     runQuery("INSERT INTO SQOOP.SQ_SUBMISSION"
-      + "(SQS_JOB, SQS_STATUS, SQS_CREATION_DATE, SQS_UPDATE_DATE,"
-      + " SQS_EXTERNAL_ID, SQS_EXTERNAL_LINK, SQS_EXCEPTION,"
-      + " SQS_EXCEPTION_TRACE)"
-      + "VALUES "
-      + "(1, 'RUNNING', '2012-01-01 01:01:01', '2012-01-01 01:01:01', 'job_1',"
-      +   "NULL, NULL, NULL),"
-      + "(2, 'SUCCEEDED', '2012-01-01 01:01:01', '2012-01-02 01:01:01', 'job_2',"
-      + " NULL, NULL, NULL),"
-      + "(3, 'FAILED', '2012-01-01 01:01:01', '2012-01-03 01:01:01', 'job_3',"
-      + " NULL, NULL, NULL),"
-      + "(4, 'UNKNOWN', '2012-01-01 01:01:01', '2012-01-04 01:01:01', 'job_4',"
-      + " NULL, NULL, NULL),"
-      + "(1, 'RUNNING', '2012-01-01 01:01:01', '2012-01-05 01:01:01', 'job_5',"
-      + " NULL, NULL, NULL)"
-    );
+        + "(SQS_JOB, SQS_STATUS, SQS_CREATION_DATE, SQS_UPDATE_DATE,"
+        + " SQS_EXTERNAL_ID, SQS_EXTERNAL_LINK, SQS_EXCEPTION," + " SQS_EXCEPTION_TRACE)"
+        + "VALUES " + "(1, 'RUNNING', '2012-01-01 01:01:01', '2012-01-01 01:01:01', 'job_1',"
+        + "NULL, NULL, NULL),"
+        + "(2, 'SUCCEEDED', '2012-01-01 01:01:01', '2012-01-02 01:01:01', 'job_2',"
+        + " NULL, NULL, NULL),"
+        + "(3, 'FAILED', '2012-01-01 01:01:01', '2012-01-03 01:01:01', 'job_3',"
+        + " NULL, NULL, NULL),"
+        + "(4, 'UNKNOWN', '2012-01-01 01:01:01', '2012-01-04 01:01:01', 'job_4',"
+        + " NULL, NULL, NULL),"
+        + "(1, 'RUNNING', '2012-01-01 01:01:01', '2012-01-05 01:01:01', 'job_5',"
+        + " NULL, NULL, NULL)");
 
     runQuery("INSERT INTO SQOOP.SQ_COUNTER_SUBMISSION "
-      + "(SQRS_GROUP, SQRS_COUNTER, SQRS_SUBMISSION, SQRS_VALUE) "
-      + "VALUES"
-      + "(1, 1, 4, 300)"
-    );
+        + "(SQRS_GROUP, SQRS_COUNTER, SQRS_SUBMISSION, SQRS_VALUE) " + "VALUES" + "(1, 1, 4, 300)");
 
   }
 
@@ -741,79 +789,76 @@ abstract public class DerbyTestCase {
   }
 
   protected MConnector getConnector(boolean from, boolean to) {
-    MFromConfig fromJobForms = null;
-    MToConfig toJobForms = null;
+    MFromConfig fromConfig = null;
+    MToConfig toConfig = null;
     if (from) {
-      fromJobForms = getFromConfig();
+      fromConfig = getFromConfig();
     }
     if (to) {
-      toJobForms = getToConfig();
+      toConfig = getToConfig();
     }
-    return new MConnector("A", "org.apache.sqoop.test.A", "1.0-test",
-      getLinkConfig(), fromJobForms, toJobForms);
+    return new MConnector("A", "org.apache.sqoop.test.A", "1.0-test", getLinkConfig(), fromConfig,
+        toConfig);
   }
-  
+
   protected MDriver getDriver() {
     return new MDriver(getDriverConfig(), DriverBean.CURRENT_DRIVER_VERSION);
   }
 
   protected void fillLink(MLink link) {
     List<MConfig> configs = link.getConnectorLinkConfig().getConfigs();
-    ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Value1");
-    ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Value2");
+    ((MStringInput) configs.get(0).getInputs().get(0)).setValue("Value1");
+    ((MStringInput) configs.get(1).getInputs().get(0)).setValue("Value2");
   }
 
   protected void fillJob(MJob job) {
     List<MConfig> configs = job.getJobConfig(Direction.FROM).getConfigs();
-    ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Value1");
-    ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Value2");
+    ((MStringInput) configs.get(0).getInputs().get(0)).setValue("Value1");
+    ((MStringInput) configs.get(1).getInputs().get(0)).setValue("Value2");
 
     configs = job.getJobConfig(Direction.TO).getConfigs();
-    ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Value1");
-    ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Value2");
+    ((MStringInput) configs.get(0).getInputs().get(0)).setValue("Value1");
+    ((MStringInput) configs.get(1).getInputs().get(0)).setValue("Value2");
 
     configs = job.getDriverConfig().getConfigs();
-    ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Value13");
-    ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Value15");
+    ((MStringInput) configs.get(0).getInputs().get(0)).setValue("Value13");
+    ((MStringInput) configs.get(1).getInputs().get(0)).setValue("Value15");
   }
 
   protected MLinkConfig getLinkConfig() {
-    return new MLinkConfig(getConfigs());
+    return new MLinkConfig(getConfigs("l1", "l2"));
   }
 
   protected MFromConfig getFromConfig() {
-    return  new MFromConfig(getConfigs());
+    return new MFromConfig(getConfigs("from1", "from2"));
   }
 
   protected MToConfig getToConfig() {
-    return new MToConfig(getConfigs());
+    return new MToConfig(getConfigs("to1", "to2"));
   }
 
   protected MDriverConfig getDriverConfig() {
-    return new MDriverConfig(getConfigs());
+    return new MDriverConfig(getConfigs("d1", "d2"));
   }
 
-  protected List<MConfig> getConfigs() {
-    List<MConfig> jobConfigs = new LinkedList<MConfig>();
+  protected List<MConfig> getConfigs(String configName1, String configName2) {
+    List<MConfig> configs = new LinkedList<MConfig>();
 
     List<MInput<?>> inputs = new LinkedList<MInput<?>>();
     MInput input = new MStringInput("I1", false, (short) 30);
     inputs.add(input);
     input = new MMapInput("I2", false);
     inputs.add(input);
-    // adding the from part of the job config
-    jobConfigs.add(new MConfig("C1", inputs));
+    configs.add(new MConfig(configName1, inputs));
 
-    // to
     inputs = new LinkedList<MInput<?>>();
-    input = new MStringInput("I3", false, (short)30);
+    input = new MStringInput("I3", false, (short) 30);
     inputs.add(input);
     input = new MMapInput("I4", false);
     inputs.add(input);
-    // adding the to part of the job config
-    jobConfigs.add(new MConfig("C2", inputs));
+    configs.add(new MConfig(configName2, inputs));
 
-    return jobConfigs;
+    return configs;
   }
 
   /**
@@ -830,15 +875,15 @@ abstract public class DerbyTestCase {
     try {
       stmt = getDerbyDatabaseConnection().createStatement();
 
-      rs = stmt.executeQuery("SELECT COUNT(*) FROM "+ table);
+      rs = stmt.executeQuery("SELECT COUNT(*) FROM " + table);
       rs.next();
 
       return rs.getLong(1);
     } finally {
-      if(stmt != null) {
+      if (stmt != null) {
         stmt.close();
       }
-      if(rs != null) {
+      if (rs != null) {
         rs.close();
       }
     }
@@ -846,13 +891,11 @@ abstract public class DerbyTestCase {
 
   /**
    * Assert row count for given table.
-   *
    * @param table Table name
    * @param expected Expected number of rows
    * @throws Exception
    */
-  protected void assertCountForTable(String table, long expected)
-    throws Exception {
+  protected void assertCountForTable(String table, long expected) throws Exception {
     long count = countForTable(table);
     assertEquals(expected, count);
   }
@@ -860,21 +903,20 @@ abstract public class DerbyTestCase {
   /**
    * Printout repository content for advance debugging.
    *
-   * This method is currently unused, but might be helpful in the future, so
-   * I'm letting it here.
+   * This method is currently unused, but might be helpful in the future, so I'm
+   * letting it here.
    *
    * @throws Exception
    */
   protected void generateDatabaseState() throws Exception {
-    for(String tbl : new String[] {"SQ_CONNECTOR", "SQ_CONFIG", "SQ_INPUT",
-      "SQ_LINK", "SQ_LINK_INPUT", "SQ_JOB", "SQ_JOB_INPUT"}) {
+    for (String tbl : new String[] { "SQ_CONNECTOR", "SQ_CONFIG", "SQ_INPUT", "SQ_LINK",
+        "SQ_LINK_INPUT", "SQ_JOB", "SQ_JOB_INPUT" }) {
       generateTableState("SQOOP." + tbl);
     }
   }
 
   /**
    * Printout one single table.
-   *
    * @param table Table name
    * @throws Exception
    */
@@ -892,15 +934,15 @@ abstract public class DerbyTestCase {
       StringBuilder sb = new StringBuilder();
       System.out.println("Table " + table + ":");
 
-      for(int i = 1; i <= rsmt.getColumnCount(); i++) {
+      for (int i = 1; i <= rsmt.getColumnCount(); i++) {
         sb.append("| ").append(rsmt.getColumnName(i)).append(" ");
       }
       sb.append("|");
       System.out.println(sb.toString());
 
-      while(rs.next()) {
+      while (rs.next()) {
         sb = new StringBuilder();
-        for(int i = 1; i <= rsmt.getColumnCount(); i++) {
+        for (int i = 1; i <= rsmt.getColumnCount(); i++) {
           sb.append("| ").append(rs.getString(i)).append(" ");
         }
         sb.append("|");
@@ -910,12 +952,12 @@ abstract public class DerbyTestCase {
       System.out.println("");
 
     } finally {
-      if(rs != null) {
+      if (rs != null) {
         rs.close();
       }
-      if(ps != null) {
+      if (ps != null) {
         ps.close();
       }
     }
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/31f30cc2/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java
index ca40545..efc4418 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java
@@ -46,10 +46,8 @@ public class TestConnectorHandling extends DerbyTestCase {
   public void testFindConnector() throws Exception {
     // On empty repository, no connectors should be there
     assertNull(handler.findConnector("A", getDerbyDatabaseConnection()));
-    assertNull(handler.findConnector("B", getDerbyDatabaseConnection()));
     // Load connector into repository
-    loadConnectorAndDriverConfig();
-
+    addConnectorA();
     // Retrieve it
     MConnector connector = handler.findConnector("A", getDerbyDatabaseConnection());
     assertNotNull(connector);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/31f30cc2/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java
index 7f35f8c..71cc763 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java
@@ -72,7 +72,8 @@ public class TestInputTypes extends DerbyTestCase {
     assertNotSame(connector.getPersistenceId(), MPersistableEntity.PERSISTANCE_ID_DEFAULT);
 
     // Retrieve registered connector
-    MConnector retrieved = handler.findConnector(connector.getUniqueName(), getDerbyDatabaseConnection());
+    MConnector retrieved = handler.findConnector(connector.getUniqueName(),
+        getDerbyDatabaseConnection());
     assertNotNull(retrieved);
 
     // Original and retrieved connectors should be the same
@@ -97,12 +98,12 @@ public class TestInputTypes extends DerbyTestCase {
 
     // Connection object with all various values
     MLink link = new MLink(connector.getPersistenceId(), connector.getLinkConfig());
-    MLinkConfig forms = link.getConnectorLinkConfig();
-    forms.getStringInput("f.String").setValue("A");
-    forms.getMapInput("f.Map").setValue(map);
-    forms.getIntegerInput("f.Integer").setValue(1);
-    forms.getBooleanInput("f.Boolean").setValue(true);
-    forms.getEnumInput("f.Enum").setValue("YES");
+    MLinkConfig linkConfig = link.getConnectorLinkConfig();
+    linkConfig.getStringInput("l1.String").setValue("A");
+    linkConfig.getMapInput("l1.Map").setValue(map);
+    linkConfig.getIntegerInput("l1.Integer").setValue(1);
+    linkConfig.getBooleanInput("l1.Boolean").setValue(true);
+    linkConfig.getEnumInput("l1.Enum").setValue("YES");
 
     // Create the link in repository
     handler.createLink(link, getDerbyDatabaseConnection());
@@ -110,12 +111,12 @@ public class TestInputTypes extends DerbyTestCase {
 
     // Retrieve created link
     MLink retrieved = handler.findLink(link.getPersistenceId(), getDerbyDatabaseConnection());
-    forms = retrieved.getConnectorLinkConfig();
-    assertEquals("A", forms.getStringInput("f.String").getValue());
-    assertEquals(map, forms.getMapInput("f.Map").getValue());
-    assertEquals(1, (int)forms.getIntegerInput("f.Integer").getValue());
-    assertEquals(true, (boolean)forms.getBooleanInput("f.Boolean").getValue());
-    assertEquals("YES", forms.getEnumInput("f.Enum").getValue());
+    linkConfig = retrieved.getConnectorLinkConfig();
+    assertEquals("A", linkConfig.getStringInput("l1.String").getValue());
+    assertEquals(map, linkConfig.getMapInput("l1.Map").getValue());
+    assertEquals(1, (int) linkConfig.getIntegerInput("l1.Integer").getValue());
+    assertEquals(true, (boolean) linkConfig.getBooleanInput("l1.Boolean").getValue());
+    assertEquals("YES", linkConfig.getEnumInput("l1.Enum").getValue());
   }
 
   /**
@@ -124,30 +125,30 @@ public class TestInputTypes extends DerbyTestCase {
    * @return Forms with all data types
    */
   @Override
-  protected List<MConfig> getConfigs() {
-    List<MConfig> forms = new LinkedList<MConfig>();
+  protected List<MConfig> getConfigs(String configName1, String configName2) {
+    List<MConfig> configs = new LinkedList<MConfig>();
 
     List<MInput<?>> inputs;
     MInput input;
 
     inputs = new LinkedList<MInput<?>>();
 
-    input = new MStringInput("f.String", false, (short)30);
+    input = new MStringInput(configName1 + ".String", false, (short) 30);
     inputs.add(input);
 
-    input = new MMapInput("f.Map", false);
+    input = new MMapInput(configName1 + ".Map", false);
     inputs.add(input);
 
-    input = new MIntegerInput("f.Integer", false);
+    input = new MIntegerInput(configName1 + ".Integer", false);
     inputs.add(input);
 
-    input = new MBooleanInput("f.Boolean", false);
+    input = new MBooleanInput(configName1 + ".Boolean", false);
     inputs.add(input);
 
-    input = new MEnumInput("f.Enum", false, new String[] {"YES", "NO"});
+    input = new MEnumInput(configName1 + ".Enum", false, new String[] { "YES", "NO" });
     inputs.add(input);
 
-    forms.add(new MConfig("f", inputs));
-    return forms;
+    configs.add(new MConfig(configName1, inputs));
+    return configs;
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/31f30cc2/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestRespositorySchemaUpgrade.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestRespositorySchemaUpgrade.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestRespositorySchemaUpgrade.java
index 7687be7..8cbe811 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestRespositorySchemaUpgrade.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestRespositorySchemaUpgrade.java
@@ -39,7 +39,8 @@ public class TestRespositorySchemaUpgrade extends DerbyTestCase {
   @Test
   public void testHasLatestRepositoryVersion() throws Exception {
     assertFalse(handler.isRespositorySuitableForUse(getDerbyDatabaseConnection()));
-    createOrUpgradeSchemaForLatestVersion(); // Test code is building the structures
+    createOrUpgradeSchemaForLatestVersion(); // Test code is building the
+                                             // structures
     assertTrue(handler.isRespositorySuitableForUse(getDerbyDatabaseConnection()));
   }
 
@@ -50,26 +51,58 @@ public class TestRespositorySchemaUpgrade extends DerbyTestCase {
     assertTrue(handler.isRespositorySuitableForUse(getDerbyDatabaseConnection()));
   }
 
-  @Test(expected=SQLIntegrityConstraintViolationException.class)
+  @Test(expected = SQLIntegrityConstraintViolationException.class)
   public void testUpgradeVersion4WithNonUniqueJobNameFailure() throws Exception {
     super.createOrUpgradeSchema(4);
-    // try loading duplicate job  names in version 4 and it should throw an exception
+    // try loading duplicate job names in version 4 and it should throw an
+    // exception
     super.loadNonUniqueJobsInVersion4();
   }
-  @Test(expected=SQLIntegrityConstraintViolationException.class)
+
+  @Test(expected = SQLIntegrityConstraintViolationException.class)
   public void testUpgradeVersion4WithNonUniqueLinkNamesAdded() throws Exception {
     super.createOrUpgradeSchema(4);
-    // try loading duplicate link names in version 4 and it should throw an exception
+    // try loading duplicate link names in version 4 and it should throw an
+    // exception
     super.loadNonUniqueLinksInVersion4();
   }
 
-  @Test(expected=SQLIntegrityConstraintViolationException.class)
+  @Test(expected = SQLIntegrityConstraintViolationException.class)
   public void testUpgradeVersion4WithNonUniqueConfigurableNamesAdded() throws Exception {
     super.createOrUpgradeSchema(4);
-    // try loading duplicate configurable names in version 4 and it should throw an exception
+    // try loading duplicate configurable names in version 4 and it should throw
+    // an exception
     super.loadNonUniqueConfigurablesInVersion4();
   }
 
+  @Test(expected = SQLIntegrityConstraintViolationException.class)
+  public void testUpgradeVersion4WithNonUniqueConfigNameAndTypeAdded() throws Exception {
+    super.createOrUpgradeSchema(4);
+    super.addConnectorB();
+    // try loading duplicate config names in version 4 and it should throw an
+    // exception
+    super.loadNonUniqueConfigNameTypeInVersion4();
+  }
+
+  @Test
+  public void testUpgradeVersion4WithNonUniqueConfigNameButUniqueTypeAdded() throws Exception {
+    super.createOrUpgradeSchema(4);
+    super.addConnectorB();
+    // try loading duplicate config names but unique type, hence no exception
+    super.loadNonUniqueConfigNameButUniqueTypeInVersion4();
+  }
+
+  @Test
+  public void testUpgradeVersion4WithNonUniqueConfigNameAndTypeButUniqueConfigurable()
+      throws Exception {
+    super.createOrUpgradeSchema(4);
+    super.addConnectorA();
+    super.addConnectorB();
+    // try loading duplicate config names and type but unique connector, hence
+    // no exception
+    super.loadNonUniqueConfigNameAndTypeButUniqueConfigurableInVersion4();
+  }
+
   @Test
   public void testUpgradeRepoVersion2ToVersion4() throws Exception {
     // in case of version 2 schema there is no unique job/ link constraint
@@ -88,7 +121,7 @@ public class TestRespositorySchemaUpgrade extends DerbyTestCase {
         runQuery("INSERT INTO SQOOP.SQ_CONNECTOR(SQC_NAME, SQC_CLASS, SQC_VERSION)"
             + "VALUES('hdfs-connector', 'org.apache.sqoop.test.B', '1.0-test')");
         return 2L;
-      } catch(Exception e) {
+      } catch (Exception e) {
         return -1L;
       }
     }