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 2014/08/19 22:44:07 UTC
[1/2] SQOOP-1449: Sqoop2: From/To: Re-enable common tests
Repository: sqoop
Updated Branches:
refs/heads/SQOOP-1367 5f04f5307 -> 3bb7ff834
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 aa58f05..27959fb 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
@@ -29,94 +29,94 @@ import org.junit.Test;
*/
public class TestMConnection {
-// /**
-// * Test for initialization
-// */
-// @Test
-// public void testInitialization() {
-// // Test default constructor
-// MConnection connection = connection();
-// assertEquals(123l, connection.getConnectorId());
-// assertEquals("Vampire", connection.getName());
-// assertEquals("Buffy", connection.getCreationUser());
-// assertEquals(forms1(), connection.getConnectorPart());
-// assertEquals(forms2(), connection.getFrameworkPart());
-//
-// // Test copy constructor
-// MConnection copy = new MConnection(connection);
-// assertEquals(123l, copy.getConnectorId());
-// assertEquals("Vampire", copy.getName());
-// assertEquals("Buffy", copy.getCreationUser());
-// assertEquals(connection.getCreationDate(), copy.getCreationDate());
-// assertEquals(forms1(), copy.getConnectorPart());
-// assertEquals(forms2(), copy.getFrameworkPart());
-//
-// // Test constructor for metadata upgrade (the order of forms is different)
-// MConnection upgradeCopy = new MConnection(connection, forms2(), forms1());
-// assertEquals(123l, upgradeCopy.getConnectorId());
-// assertEquals("Vampire", upgradeCopy.getName());
-// assertEquals("Buffy", upgradeCopy.getCreationUser());
-// assertEquals(connection.getCreationDate(), upgradeCopy.getCreationDate());
-// assertEquals(forms2(), upgradeCopy.getConnectorPart());
-// assertEquals(forms1(), upgradeCopy.getFrameworkPart());
-// }
-//
-// @Test
-// public void testClone() {
-// MConnection connection = connection();
-//
-// // Clone without value
-// MConnection withoutValue = connection.clone(false);
-// assertEquals(connection, withoutValue);
-// assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutValue.getPersistenceId());
-// assertNull(withoutValue.getName());
-// assertNull(withoutValue.getCreationUser());
-// assertEquals(forms1(), withoutValue.getConnectorPart());
-// assertEquals(forms2(), withoutValue.getFrameworkPart());
-// assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
-// assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue());
-//
-// // Clone with value
-// MConnection withValue = connection.clone(true);
-// assertEquals(connection, withValue);
-// assertEquals(connection.getPersistenceId(), withValue.getPersistenceId());
-// assertEquals(connection.getName(), withValue.getName());
-// assertEquals(connection.getCreationUser(), withValue.getCreationUser());
-// assertEquals(forms1(), withValue.getConnectorPart());
-// assertEquals(forms2(), withValue.getFrameworkPart());
-// assertEquals(100, withValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
-// assertEquals("TEST-VALUE", withValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue());
-// }
-//
-// private MConnection connection() {
-// MConnection connection = new MConnection(123l, forms1(), forms2());
-// connection.setName("Vampire");
-// connection.setCreationUser("Buffy");
-// return connection;
-// }
-//
-// private MConnectionForms forms1() {
-// List<MForm> forms = new ArrayList<MForm>();
-// MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
-// input.setValue(100);
-// MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
-// strInput.setValue("TEST-VALUE");
-// List<MInput<?>> list = new ArrayList<MInput<?>>();
-// list.add(input);
-// list.add(strInput);
-// MForm form = new MForm("FORMNAME", list);
-// forms.add(form);
-// return new MConnectionForms(forms);
-// }
-//
-// private MConnectionForms forms2() {
-// List<MForm> forms = new ArrayList<MForm>();
-// MMapInput input = new MMapInput("MAP-INPUT", false);
-// List<MInput<?>> list = new ArrayList<MInput<?>>();
-// list.add(input);
-// MForm form = new MForm("form", list);
-// forms.add(form);
-// return new MConnectionForms(forms);
-// }
+ /**
+ * Test for initialization
+ */
+ @Test
+ public void testInitialization() {
+ // Test default constructor
+ MConnection connection = connection();
+ assertEquals(123l, connection.getConnectorId());
+ assertEquals("Vampire", connection.getName());
+ assertEquals("Buffy", connection.getCreationUser());
+ assertEquals(forms1(), connection.getConnectorPart());
+ assertEquals(forms2(), connection.getFrameworkPart());
+
+ // Test copy constructor
+ MConnection copy = new MConnection(connection);
+ assertEquals(123l, copy.getConnectorId());
+ assertEquals("Vampire", copy.getName());
+ assertEquals("Buffy", copy.getCreationUser());
+ assertEquals(connection.getCreationDate(), copy.getCreationDate());
+ assertEquals(forms1(), copy.getConnectorPart());
+ assertEquals(forms2(), copy.getFrameworkPart());
+
+ // Test constructor for metadata upgrade (the order of forms is different)
+ MConnection upgradeCopy = new MConnection(connection, forms2(), forms1());
+ assertEquals(123l, upgradeCopy.getConnectorId());
+ assertEquals("Vampire", upgradeCopy.getName());
+ assertEquals("Buffy", upgradeCopy.getCreationUser());
+ assertEquals(connection.getCreationDate(), upgradeCopy.getCreationDate());
+ assertEquals(forms2(), upgradeCopy.getConnectorPart());
+ assertEquals(forms1(), upgradeCopy.getFrameworkPart());
+ }
+
+ @Test
+ public void testClone() {
+ MConnection connection = connection();
+
+ // Clone without value
+ MConnection withoutValue = connection.clone(false);
+ assertEquals(connection, withoutValue);
+ assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutValue.getPersistenceId());
+ assertNull(withoutValue.getName());
+ assertNull(withoutValue.getCreationUser());
+ assertEquals(forms1(), withoutValue.getConnectorPart());
+ assertEquals(forms2(), withoutValue.getFrameworkPart());
+ assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
+ assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue());
+
+ // Clone with value
+ MConnection withValue = connection.clone(true);
+ assertEquals(connection, withValue);
+ assertEquals(connection.getPersistenceId(), withValue.getPersistenceId());
+ assertEquals(connection.getName(), withValue.getName());
+ assertEquals(connection.getCreationUser(), withValue.getCreationUser());
+ assertEquals(forms1(), withValue.getConnectorPart());
+ assertEquals(forms2(), withValue.getFrameworkPart());
+ assertEquals(100, withValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
+ assertEquals("TEST-VALUE", withValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue());
+ }
+
+ private MConnection connection() {
+ MConnection connection = new MConnection(123l, forms1(), forms2());
+ connection.setName("Vampire");
+ connection.setCreationUser("Buffy");
+ return connection;
+ }
+
+ private MConnectionForms forms1() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
+ input.setValue(100);
+ MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
+ strInput.setValue("TEST-VALUE");
+ List<MInput<?>> list = new ArrayList<MInput<?>>();
+ list.add(input);
+ list.add(strInput);
+ MForm form = new MForm("FORMNAME", list);
+ forms.add(form);
+ return new MConnectionForms(forms);
+ }
+
+ private MConnectionForms forms2() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MMapInput input = new MMapInput("MAP-INPUT", false);
+ List<MInput<?>> list = new ArrayList<MInput<?>>();
+ list.add(input);
+ MForm form = new MForm("form", list);
+ forms.add(form);
+ return new MConnectionForms(forms);
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java b/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java
index 0899dc3..e2d2717 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java
@@ -29,20 +29,20 @@ import org.junit.Test;
*/
public class TestMConnectionForms {
-// /**
-// * Test for class initialization and values
-// */
-// @Test
-// public void testInitialization() {
-// List<MForm> forms = new ArrayList<MForm>();
-// MConnectionForms connectionForms1 = new MConnectionForms(forms);
-// List<MForm> testForms = new ArrayList<MForm>();
-// assertEquals(testForms, connectionForms1.getForms());
-// MConnectionForms connectionForms2 = new MConnectionForms(testForms);
-// assertEquals(connectionForms2, connectionForms1);
-// // Add a form to list for checking not equals
-// MForm m = new MForm("test", null);
-// testForms.add(m);
-// assertFalse(connectionForms1.equals(connectionForms2));
-// }
+ /**
+ * Test for class initialization and values
+ */
+ @Test
+ public void testInitialization() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MConnectionForms connectionForms1 = new MConnectionForms(forms);
+ List<MForm> testForms = new ArrayList<MForm>();
+ assertEquals(testForms, connectionForms1.getForms());
+ MConnectionForms connectionForms2 = new MConnectionForms(testForms);
+ assertEquals(connectionForms2, connectionForms1);
+ // Add a form to list for checking not equals
+ MForm m = new MForm("test", null);
+ testForms.add(m);
+ assertFalse(connectionForms1.equals(connectionForms2));
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 b94c7de..9672d9d 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
@@ -29,42 +29,42 @@ import org.junit.Test;
*/
public class TestMConnector {
-// /**
-// * Test for initialization
-// */
-// @Test
-// public void testInitialization() {
-// List<MForm> forms = new ArrayList<MForm>();
-// MConnectionForms connectionForms1 = new MConnectionForms(forms);
-// MJobForms jobform1 = new MJobForms(MJob.Type.EXPORT, forms);
-// List<MJobForms> jobFormList = new ArrayList<MJobForms>();
-// jobFormList.add(jobform1);
-// MConnector connector1 = new MConnector("NAME", "CLASSNAME", "1.0",
-// connectionForms1, jobFormList);
-// assertEquals("NAME", connector1.getUniqueName());
-// assertEquals("CLASSNAME", connector1.getClassName());
-// assertEquals("1.0", connector1.getVersion());
-// MConnector connector2 = new MConnector("NAME", "CLASSNAME", "1.0",
-// connectionForms1, jobFormList);
-// assertEquals(connector2, connector1);
-// MConnector connector3 = new MConnector("NAME1", "CLASSNAME", "2.0",
-// connectionForms1, jobFormList);
-// assertFalse(connector1.equals(connector3));
-//
-// try {
-// connector1 = new MConnector(null, "CLASSNAME", "1.0", connectionForms1,
-// jobFormList); // Expecting null pointer exception
-// } catch (NullPointerException e) {
-// assertTrue(true);
-// }
-// try {
-// connector1 = new MConnector("NAME", null, "1.0", connectionForms1,
-// jobFormList); // Expecting null pointer exception
-// } catch (NullPointerException e) {
-// assertTrue(true);
-// }
-// }
-//
+ /**
+ * Test for initialization
+ */
+ @Test
+ public void testInitialization() {
+ List<MForm> fromJobForms = new ArrayList<MForm>();
+ List<MForm> toJobForms = new ArrayList<MForm>();
+ MConnectionForms connectionForms1 = new MConnectionForms(fromJobForms);
+ MJobForms fromJobForm1 = new MJobForms(fromJobForms);
+ MJobForms toJobForm1 = new MJobForms(toJobForms);
+ MConnector connector1 = new MConnector("NAME", "CLASSNAME", "1.0",
+ connectionForms1, fromJobForm1, toJobForm1);
+ assertEquals("NAME", connector1.getUniqueName());
+ assertEquals("CLASSNAME", connector1.getClassName());
+ assertEquals("1.0", connector1.getVersion());
+ MConnector connector2 = new MConnector("NAME", "CLASSNAME", "1.0",
+ connectionForms1, fromJobForm1, toJobForm1);
+ assertEquals(connector2, connector1);
+ MConnector connector3 = new MConnector("NAME1", "CLASSNAME", "2.0",
+ connectionForms1, fromJobForm1, toJobForm1);
+ assertFalse(connector1.equals(connector3));
+
+ try {
+ connector1 = new MConnector(null, "CLASSNAME", "1.0", connectionForms1,
+ fromJobForm1, toJobForm1); // Expecting null pointer exception
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ }
+ try {
+ connector1 = new MConnector("NAME", null, "1.0", connectionForms1,
+ fromJobForm1, toJobForm1); // Expecting null pointer exception
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ }
+ }
+
// @Test
// public void testClone() {
// List<MForm> forms = new ArrayList<MForm>();
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 97baa32..a25016a 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
@@ -26,38 +26,38 @@ import org.junit.Test;
*/
public class TestMEnumInput {
-// public enum Enumeration { value1, value2}
-// /**
-// * Test for class initialization
-// */
-// @Test
-// public void testInitialization() {
-// String[] values = { "value1", "value2" };
-// MEnumInput input = new MEnumInput("NAME", false, values);
-// assertEquals("NAME", input.getName());
-// assertArrayEquals(values, input.getValues());
-// assertEquals(MInputType.ENUM, input.getType());
-//
-// MEnumInput input1 = new MEnumInput("NAME", false, values);
-// assertEquals(input1, input);
-// String[] testVal = { "val", "test" };
-// MEnumInput input2 = new MEnumInput("NAME1", false, testVal);
-// assertFalse(input1.equals(input2));
-//
-// MEnumInput input3 = new MEnumInput("NAME", false, values);
-// input3.setValue(Enumeration.value1);
-// assertEquals("value1", input3.getValue());
-// }
-//
-// /**
-// * Test for sensitivity
-// */
-// @Test
-// public void testSensitivity() {
-// String[] values = { "value1", "value2" };
-// MEnumInput input1 = new MEnumInput("NAME", false, values);
-// MEnumInput input2 = new MEnumInput("NAME", true, values);
-// assertFalse(input1.isSensitive());
-// assertTrue(input2.isSensitive());
-// }
+ public enum Enumeration { value1, value2}
+ /**
+ * Test for class initialization
+ */
+ @Test
+ public void testInitialization() {
+ String[] values = { "value1", "value2" };
+ MEnumInput input = new MEnumInput("NAME", false, values);
+ assertEquals("NAME", input.getName());
+ assertArrayEquals(values, input.getValues());
+ assertEquals(MInputType.ENUM, input.getType());
+
+ MEnumInput input1 = new MEnumInput("NAME", false, values);
+ assertEquals(input1, input);
+ String[] testVal = { "val", "test" };
+ MEnumInput input2 = new MEnumInput("NAME1", false, testVal);
+ assertFalse(input1.equals(input2));
+
+ MEnumInput input3 = new MEnumInput("NAME", false, values);
+ input3.setValue(Enumeration.value1);
+ assertEquals("value1", input3.getValue());
+ }
+
+ /**
+ * Test for sensitivity
+ */
+ @Test
+ public void testSensitivity() {
+ String[] values = { "value1", "value2" };
+ MEnumInput input1 = new MEnumInput("NAME", false, values);
+ MEnumInput input2 = new MEnumInput("NAME", true, values);
+ assertFalse(input1.isSensitive());
+ assertTrue(input2.isSensitive());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 109f1f5..0bd55d9 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMForm.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMForm.java
@@ -28,61 +28,61 @@ import org.junit.Test;
*/
public class TestMForm {
-// /**
-// * Test for initialization
-// */
-// @Test
-// public void testInitialization() {
-// MInput<String> input1 = new MStringInput("sqoopsqoop1", true, (short) 5);
-// MInput<String> input2 = new MStringInput("sqoopsqoop2", true, (short) 5);
-//
-// List<MInput<?>> list = new ArrayList<MInput<?>>();
-// list.add(input1);
-// list.add(input2);
-// MForm mform = new MForm("form", list);
-//
-// assertEquals("form", mform.getName());
-// assertEquals(2, mform.getInputs().size());
-// }
-//
-// /**
-// * Test for equals method
-// */
-// @Test
-// public void testEquals() {
-// MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1", false);
-// MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2", false);
-// List<MInput<?>> list1 = new ArrayList<MInput<?>>();
-// list1.add(input1);
-// list1.add(input2);
-// MForm mform1 = new MForm("form", list1);
-//
-// MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false);
-// MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false);
-// List<MInput<?>> list2 = new ArrayList<MInput<?>>();
-// list2.add(input3);
-// list2.add(input4);
-// MForm mform2 = new MForm("form", list2);
-// assertEquals(mform2, mform1);
-// }
-//
-// @Test
-// public void testGetInputs() {
-// MIntegerInput intInput = new MIntegerInput("Form.A", false);
-// MMapInput mapInput = new MMapInput("Form.B", false);
-// MStringInput stringInput = new MStringInput("Form.C", false, (short)3);
-// MEnumInput enumInput = new MEnumInput("Form.D", false, 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"));
-// }
+ /**
+ * Test for initialization
+ */
+ @Test
+ public void testInitialization() {
+ MInput<String> input1 = new MStringInput("sqoopsqoop1", true, (short) 5);
+ MInput<String> input2 = new MStringInput("sqoopsqoop2", true, (short) 5);
+
+ List<MInput<?>> list = new ArrayList<MInput<?>>();
+ list.add(input1);
+ list.add(input2);
+ MForm mform = new MForm("form", list);
+
+ assertEquals("form", mform.getName());
+ assertEquals(2, mform.getInputs().size());
+ }
+
+ /**
+ * Test for equals method
+ */
+ @Test
+ public void testEquals() {
+ MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1", false);
+ MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2", false);
+ List<MInput<?>> list1 = new ArrayList<MInput<?>>();
+ list1.add(input1);
+ list1.add(input2);
+ MForm mform1 = new MForm("form", list1);
+
+ MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false);
+ MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false);
+ List<MInput<?>> list2 = new ArrayList<MInput<?>>();
+ list2.add(input3);
+ list2.add(input4);
+ MForm mform2 = new MForm("form", list2);
+ assertEquals(mform2, mform1);
+ }
+
+ @Test
+ public void testGetInputs() {
+ MIntegerInput intInput = new MIntegerInput("Form.A", false);
+ MMapInput mapInput = new MMapInput("Form.B", false);
+ MStringInput stringInput = new MStringInput("Form.C", false, (short)3);
+ MEnumInput enumInput = new MEnumInput("Form.D", false, 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/3bb7ff83/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
index 4894d2e..c7ee682 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
@@ -29,30 +29,30 @@ 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", false);
-// MMapInput mapInput = new MMapInput("Form1.B", false);
-//
-// 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", false, 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"));
-// }
+ @Test
+ public void testGetInputs() {
+ List<MForm> forms = new LinkedList<MForm>();
+
+ MIntegerInput intInput = new MIntegerInput("Form1.A", false);
+ MMapInput mapInput = new MMapInput("Form1.B", false);
+
+ 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", false, 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/3bb7ff83/common/src/test/java/org/apache/sqoop/model/TestMFramework.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMFramework.java b/common/src/test/java/org/apache/sqoop/model/TestMFramework.java
index d0720f0..5273a90 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMFramework.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMFramework.java
@@ -29,18 +29,19 @@ import static org.junit.Assert.*;
*/
public class TestMFramework {
-// @Test
-// public void testFailureOnDuplicateJobTypes() {
-// MConnectionForms connectionForms = new MConnectionForms(new ArrayList<MForm>());
-// List<MJobForms> jobForms = new ArrayList<MJobForms>();
-// jobForms.add(new MJobForms(MJob.Type.IMPORT, new ArrayList<MForm>()));
-// jobForms.add(new MJobForms(MJob.Type.IMPORT, new ArrayList<MForm>()));
-//
-// try {
-// new MFramework(connectionForms, jobForms, "1");
-// fail("We we're expecting exception for invalid usage");
-// } catch(Exception ex) {
-// // Expected case
-// }
-// }
+ @Test
+ public void testForms() {
+ List<MForm> connectionFormList = new ArrayList<MForm>();
+ List<MForm> jobFormList = new ArrayList<MForm>();
+ connectionFormList.add(new MForm("connection-test", new ArrayList<MInput<?>>()));
+ jobFormList.add(new MForm("job-test", new ArrayList<MInput<?>>()));
+ MConnectionForms connectionForms = new MConnectionForms(connectionFormList);
+ MJobForms jobForms = new MJobForms(jobFormList);
+
+ MFramework framework = new MFramework(connectionForms, jobForms, "1");
+ assertEquals(1, framework.getJobForms().getForms().size());
+ assertEquals("job-test", framework.getJobForms().getForms().get(0).getName());
+ assertEquals(1, framework.getConnectionForms().getForms().size());
+ assertEquals("connection-test", framework.getConnectionForms().getForms().get(0).getName());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 14bca67..1f38e6d 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
@@ -28,76 +28,76 @@ import org.junit.Test;
* Test class for org.apache.sqoop.model.MInputInput
*/
public class TestMIntegerInput {
-// /**
-// * Test for class initialization
-// */
-// @Test
-// public void testInitialization() {
-// MIntegerInput input = new MIntegerInput("sqoopsqoop", false);
-// assertEquals("sqoopsqoop", input.getName());
-// assertEquals(MInputType.INTEGER, input.getType());
-// }
-//
-// /**
-// * Test for equals() method
-// */
-// @Test
-// public void testEquals() {
-// // Positive test
-// MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
-// MIntegerInput input2 = new MIntegerInput("sqoopsqoop", false);
-// assertTrue(input1.equals(input2));
-//
-// // Negative test
-// MIntegerInput input3 = new MIntegerInput("sqoopsqoop", false);
-// MIntegerInput input4 = new MIntegerInput("sqoopsqoop1", false);
-// assertFalse(input3.equals(input4));
-// }
-//
-// /**
-// * Test for value
-// */
-// @Test
-// public void testValue() {
-// MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
-// input1.setValue(99);
-// assertEquals(new Integer(99), input1.getValue());
-// input1.setEmpty();
-// assertNull(input1.getValue());
-// }
-//
-// /**
-// * Test for getUrlSafeValueString() and restoreFromUrlSafeValueString()
-// */
-// @Test
-// public void testUrlSafe() {
-// MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
-// input1.setValue(1001);
-// // Getting URL safe string
-// String tmp = input1.getUrlSafeValueString();
-// // Restore to actual value
-// input1.restoreFromUrlSafeValueString(tmp);
-// assertEquals(new Integer(1001), input1.getValue());
-// }
-//
-// /**
-// * Test case for MNamedElement.getLabelKey() and MNamedElement.getHelpKey()
-// */
-// @Test
-// public void testNamedElement() {
-// MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
-// assertEquals("sqoopsqoop.label", input1.getLabelKey());
-// assertEquals("sqoopsqoop.help", input1.getHelpKey());
-// }
-//
-// /**
-// * Test for sensitivity
-// */
-// @Test
-// public void testSensitivity() {
-// MIntegerInput input1 = new MIntegerInput("NAME", false);
-// MIntegerInput input2 = new MIntegerInput("NAME", true);
-// assertFalse(input1.isSensitive());
-// assertTrue(input2.isSensitive());
-// }
+ /**
+ * Test for class initialization
+ */
+ @Test
+ public void testInitialization() {
+ MIntegerInput input = new MIntegerInput("sqoopsqoop", false);
+ assertEquals("sqoopsqoop", input.getName());
+ assertEquals(MInputType.INTEGER, input.getType());
+ }
+
+ /**
+ * Test for equals() method
+ */
+ @Test
+ public void testEquals() {
+ // Positive test
+ MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
+ MIntegerInput input2 = new MIntegerInput("sqoopsqoop", false);
+ assertTrue(input1.equals(input2));
+
+ // Negative test
+ MIntegerInput input3 = new MIntegerInput("sqoopsqoop", false);
+ MIntegerInput input4 = new MIntegerInput("sqoopsqoop1", false);
+ assertFalse(input3.equals(input4));
+ }
+
+ /**
+ * Test for value
+ */
+ @Test
+ public void testValue() {
+ MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
+ input1.setValue(99);
+ assertEquals(new Integer(99), input1.getValue());
+ input1.setEmpty();
+ assertNull(input1.getValue());
+ }
+
+ /**
+ * Test for getUrlSafeValueString() and restoreFromUrlSafeValueString()
+ */
+ @Test
+ public void testUrlSafe() {
+ MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
+ input1.setValue(1001);
+ // Getting URL safe string
+ String tmp = input1.getUrlSafeValueString();
+ // Restore to actual value
+ input1.restoreFromUrlSafeValueString(tmp);
+ assertEquals(new Integer(1001), input1.getValue());
+ }
+
+ /**
+ * Test case for MNamedElement.getLabelKey() and MNamedElement.getHelpKey()
+ */
+ @Test
+ public void testNamedElement() {
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ assertEquals("sqoopsqoop.label", input1.getLabelKey());
+ assertEquals("sqoopsqoop.help", input1.getHelpKey());
+ }
+
+ /**
+ * Test for sensitivity
+ */
+ @Test
+ public void testSensitivity() {
+ MIntegerInput input1 = new MIntegerInput("NAME", false);
+ MIntegerInput input2 = new MIntegerInput("NAME", true);
+ assertFalse(input1.isSensitive());
+ assertTrue(input2.isSensitive());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 355cdb9..96c316a 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMJob.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
@@ -22,114 +22,119 @@ import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
-import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.common.Direction;
import org.junit.Test;
/**
* Test class for org.apache.sqoop.model.MJob
*/
public class TestMJob {
-// /**
-// * Test class for initialization
-// */
-// @Test
-// public void testInitialization() {
-// // Test default constructor
-// MJob job = job(MJob.Type.IMPORT);
-// assertEquals(123l, job.getFromConnectorId());
-// assertEquals(MJob.Type.IMPORT, job.getType());
-// assertEquals("Buffy", job.getCreationUser());
-// assertEquals("Vampire", job.getName());
-// assertEquals(forms1(MJob.Type.IMPORT), job.getFromPart());
-// assertEquals(forms2(MJob.Type.IMPORT), job.getFrameworkPart());
-//
-// // Test copy constructor
-// MJob copy = new MJob(job);
-// assertEquals(123l, copy.getFromConnectorId());
-// assertEquals(MJob.Type.IMPORT, copy.getType());
-// assertEquals("Vampire", copy.getName());
-// assertEquals("Buffy", copy.getCreationUser());
-// assertEquals(job.getCreationDate(), copy.getCreationDate());
-// assertEquals(forms1(MJob.Type.IMPORT), copy.getFromPart());
-// assertEquals(forms2(MJob.Type.IMPORT), copy.getFrameworkPart());
-//
-// // Test constructor for metadata upgrade (the order of forms is different)
-// MJob upgradeCopy = new MJob(job, forms2(MJob.Type.IMPORT), forms1(MJob.Type.IMPORT));
-// assertEquals(123l, upgradeCopy.getFromConnectorId());
-// assertEquals(MJob.Type.IMPORT, upgradeCopy.getType());
-// assertEquals("Vampire", upgradeCopy.getName());
-// assertEquals("Buffy", upgradeCopy.getCreationUser());
-// assertEquals(job.getCreationDate(), upgradeCopy.getCreationDate());
-// assertEquals(forms2(MJob.Type.IMPORT), upgradeCopy.getFromPart());
-// assertEquals(forms1(MJob.Type.IMPORT), upgradeCopy.getFrameworkPart());
-// }
-//
-// @Test(expected = SqoopException.class)
-// public void testIncorrectDefaultConstructor() {
-// new MJob(1l, 1l, MJob.Type.IMPORT, forms1(MJob.Type.IMPORT), forms2(MJob.Type.EXPORT));
-// }
-//
-// @Test(expected = SqoopException.class)
-// public void testIncorrectUpgradeConstructor() {
-// new MJob(job(MJob.Type.EXPORT), forms1(MJob.Type.IMPORT), forms2(MJob.Type.IMPORT));
-// }
-//
-// @Test
-// public void testClone() {
-// MJob job = job(MJob.Type.IMPORT);
-//
-// // Clone without value
-// MJob withoutValue = job.clone(false);
-// assertEquals(job, withoutValue);
-// assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutValue.getPersistenceId());
-// assertEquals(MJob.Type.IMPORT, withoutValue.getType());
-// assertNull(withoutValue.getName());
-// assertNull(withoutValue.getCreationUser());
-// assertEquals(forms1(MJob.Type.IMPORT), withoutValue.getFromPart());
-// assertEquals(forms2(MJob.Type.IMPORT), withoutValue.getFrameworkPart());
-// assertNull(withoutValue.getFromPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
-// assertNull(withoutValue.getFromPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue());
-//
-// // Clone with value
-// MJob withValue = job.clone(true);
-// assertEquals(job, withValue);
-// assertEquals(job.getPersistenceId(), withValue.getPersistenceId());
-// assertEquals(MJob.Type.IMPORT, withValue.getType());
-// assertEquals(job.getName(), withValue.getName());
-// assertEquals(job.getCreationUser(), withValue.getCreationUser());
-// assertEquals(forms1(MJob.Type.IMPORT), withValue.getFromPart());
-// assertEquals(forms2(MJob.Type.IMPORT), withValue.getFrameworkPart());
-// assertEquals(100, withValue.getFromPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
-// assertEquals("TEST-VALUE", withValue.getFromPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue()); }
-//
-// private MJob job(MJob.Type type) {
-// MJob job = new MJob(123l, 456l, type, forms1(type), forms2(type));
-// job.setName("Vampire");
-// job.setCreationUser("Buffy");
-// return job;
-// }
-//
-// private MJobForms forms1(MJob.Type type) {
-// List<MForm> forms = new ArrayList<MForm>();
-// MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
-// input.setValue(100);
-// MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
-// strInput.setValue("TEST-VALUE");
-// List<MInput<?>> list = new ArrayList<MInput<?>>();
-// list.add(input);
-// list.add(strInput);
-// MForm form = new MForm("FORMNAME", list);
-// forms.add(form);
-// return new MJobForms(type, forms);
-// }
-//
-// private MJobForms forms2(MJob.Type type) {
-// List<MForm> forms = new ArrayList<MForm>();
-// MMapInput input = new MMapInput("MAP-INPUT", false);
-// List<MInput<?>> list = new ArrayList<MInput<?>>();
-// list.add(input);
-// MForm form = new MForm("form", list);
-// forms.add(form);
-// return new MJobForms(type, forms);
-// }
+ /**
+ * Test class for initialization
+ */
+ @Test
+ public void testInitialization() {
+ // Test default constructor
+ MJob job = job();
+ assertEquals(123l, job.getConnectorId(Direction.FROM));
+ assertEquals(456l, job.getConnectorId(Direction.TO));
+ assertEquals("Buffy", job.getCreationUser());
+ assertEquals("Vampire", job.getName());
+ assertEquals(fromForms(), job.getConnectorPart(Direction.FROM));
+ assertEquals(toForms(), job.getConnectorPart(Direction.TO));
+ assertEquals(frameworkForms(), job.getFrameworkPart());
+
+ // Test copy constructor
+ MJob copy = new MJob(job);
+ assertEquals(123l, copy.getConnectorId(Direction.FROM));
+ assertEquals(456l, copy.getConnectorId(Direction.TO));
+ assertEquals("Buffy", copy.getCreationUser());
+ assertEquals("Vampire", copy.getName());
+ assertEquals(fromForms(), copy.getConnectorPart(Direction.FROM));
+ assertEquals(toForms(), copy.getConnectorPart(Direction.TO));
+ assertEquals(frameworkForms(), copy.getFrameworkPart());
+
+ // Test constructor for metadata upgrade (the order of forms is different)
+ MJob upgradeCopy = new MJob(job, fromForms(), toForms(), frameworkForms());
+ assertEquals(123l, upgradeCopy.getConnectorId(Direction.FROM));
+ assertEquals(456l, upgradeCopy.getConnectorId(Direction.TO));
+ assertEquals("Buffy", upgradeCopy.getCreationUser());
+ assertEquals("Vampire", upgradeCopy.getName());
+ assertEquals(fromForms(), upgradeCopy.getConnectorPart(Direction.FROM));
+ assertEquals(toForms(), upgradeCopy.getConnectorPart(Direction.TO));
+ assertEquals(frameworkForms(), upgradeCopy.getFrameworkPart());
+ }
+
+ @Test
+ public void testClone() {
+ MJob job = job();
+
+ // Clone without value
+ MJob withoutValue = job.clone(false);
+ assertEquals(job, withoutValue);
+ assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutValue.getPersistenceId());
+ assertNull(withoutValue.getName());
+ assertNull(withoutValue.getCreationUser());
+ assertEquals(fromForms(), withoutValue.getConnectorPart(Direction.FROM));
+ assertEquals(toForms(), withoutValue.getConnectorPart(Direction.TO));
+ assertEquals(frameworkForms(), withoutValue.getFrameworkPart());
+ assertNull(withoutValue.getConnectorPart(Direction.FROM)
+ .getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
+ assertNull(withoutValue.getConnectorPart(Direction.FROM)
+ .getForm("FORMNAME").getInput("STRING-INPUT").getValue());
+
+ // Clone with value
+ MJob withValue = job.clone(true);
+ assertEquals(job, withValue);
+ assertEquals(job.getPersistenceId(), withValue.getPersistenceId());
+ assertEquals(job.getName(), withValue.getName());
+ assertEquals(job.getCreationUser(), withValue.getCreationUser());
+ assertEquals(fromForms(), withValue.getConnectorPart(Direction.FROM));
+ assertEquals(toForms(), withValue.getConnectorPart(Direction.TO));
+ assertEquals(frameworkForms(), withValue.getFrameworkPart());
+ assertEquals(100, withValue.getConnectorPart(Direction.FROM)
+ .getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
+ assertEquals("TEST-VALUE", withValue.getConnectorPart(Direction.FROM)
+ .getForm("FORMNAME").getInput("STRING-INPUT").getValue()); }
+
+ private MJob job() {
+ MJob job = new MJob(123l, 456l, 1L, 2L, fromForms(), toForms(), frameworkForms());
+ job.setName("Vampire");
+ job.setCreationUser("Buffy");
+ return job;
+ }
+
+ private MJobForms fromForms() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
+ input.setValue(100);
+ MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
+ strInput.setValue("TEST-VALUE");
+ List<MInput<?>> list = new ArrayList<MInput<?>>();
+ list.add(input);
+ list.add(strInput);
+ MForm form = new MForm("FORMNAME", list);
+ forms.add(form);
+ return new MJobForms(forms);
+ }
+
+ private MJobForms toForms() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MMapInput input = new MMapInput("MAP-INPUT", false);
+ List<MInput<?>> list = new ArrayList<MInput<?>>();
+ list.add(input);
+ MForm form = new MForm("form", list);
+ forms.add(form);
+ return new MJobForms(forms);
+ }
+
+ private MJobForms frameworkForms() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MMapInput input = new MMapInput("MAP-INPUT", false);
+ List<MInput<?>> list = new ArrayList<MInput<?>>();
+ list.add(input);
+ MForm form = new MForm("form", list);
+ forms.add(form);
+ return new MJobForms(forms);
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java b/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java
index 5c44c0a..81a8614 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java
@@ -28,20 +28,19 @@ import org.junit.Test;
* Test class for org.apache.sqoop.model.MJobForms
*/
public class TestMJobForms {
-// /**
-// * Test for class initialization and values
-// */
-// @Test
-// public void testInitialization() {
-// List<MForm> forms = new ArrayList<MForm>();
-// MJobForms jobform1 = new MJobForms(MJob.Type.EXPORT, forms);
-// assertEquals(MJob.Type.EXPORT, jobform1.getType());
-// List<MForm> forms2 = new ArrayList<MForm>();
-// MJobForms jobform2 = new MJobForms(MJob.Type.EXPORT, forms2);
-// assertEquals(jobform2, jobform1);
-// // Add a form to list for checking not equals
-// MForm m = new MForm("test", null);
-// forms2.add(m);
-// assertFalse(jobform1.equals(jobform2));
-// }
+ /**
+ * Test for class initialization and values
+ */
+ @Test
+ public void testInitialization() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MJobForms jobform1 = new MJobForms(forms);
+ List<MForm> forms2 = new ArrayList<MForm>();
+ MJobForms jobform2 = new MJobForms(forms2);
+ assertEquals(jobform2, jobform1);
+ // Add a form to list for checking not equals
+ MForm m = new MForm("test", null);
+ forms2.add(m);
+ assertFalse(jobform1.equals(jobform2));
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 99d147c..120fb07 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
@@ -32,84 +32,84 @@ import org.junit.Test;
* Test class for org.apache.sqoop.model.MMapInput
*/
public class TestMMapInput {
-// /**
-// * Test for class initialization
-// */
-// @Test
-// public void testInitialization() {
-// MMapInput input = new MMapInput("sqoopsqoop", false);
-// assertEquals("sqoopsqoop", input.getName());
-// assertEquals(MInputType.MAP, input.getType());
-// }
-//
-// /**
-// * Test for equals() method
-// */
-// @Test
-// public void testEquals() {
-// // Positive test
-// MMapInput input1 = new MMapInput("sqoopsqoop", false);
-// MMapInput input2 = new MMapInput("sqoopsqoop", false);
-// assertTrue(input1.equals(input2));
-//
-// // Negative test
-// MMapInput input3 = new MMapInput("sqoopsqoop", false);
-// MMapInput input4 = new MMapInput("sqoopsqoop1", false);
-// assertFalse(input3.equals(input4));
-// }
-//
-// /**
-// * Test for value
-// */
-// @Test
-// public void testValue() {
-// MMapInput input1 = new MMapInput("sqoopsqoop", false);
-// Map<String, String> map1 = new HashMap<String, String>();
-// input1.setValue(map1);
-// assertEquals(map1, input1.getValue());
-// input1.setEmpty();
-// assertNull(input1.getValue());
-// }
-//
-// /**
-// * Test for getUrlSafeValueString() and restoreFromUrlSafeValueString()
-// */
-// @Test
-// public void testUrlSafe() {
-// MMapInput input1 = new MMapInput("sqoopsqoop", false);
-// Map<String, String> map1 = new HashMap<String, String>();
-// input1.setValue(map1);
-// // Getting URL safe string
-// String tmp = input1.getUrlSafeValueString();
-// // Restore to actual value
-// input1.restoreFromUrlSafeValueString(tmp);
-// assertNotNull(input1.getValue());
-// assertEquals(0, input1.getValue().size());
-//
-// input1.setValue(null);
-// tmp = input1.getUrlSafeValueString();
-// input1.restoreFromUrlSafeValueString(tmp);
-// assertNull(input1.getValue());
-// }
-//
-// /**
-// * Test case for MNamedElement.getLabelKey() and MNamedElement.getHelpKey()
-// */
-// @Test
-// public void testNamedElement() {
-// MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
-// assertEquals("sqoopsqoop.label", input1.getLabelKey());
-// assertEquals("sqoopsqoop.help", input1.getHelpKey());
-// }
-//
-// /**
-// * Test for sensitivity
-// */
-// @Test
-// public void testSensitivity() {
-// MMapInput input1 = new MMapInput("NAME", false);
-// MMapInput input2 = new MMapInput("NAME", true);
-// assertFalse(input1.isSensitive());
-// assertTrue(input2.isSensitive());
-// }
+ /**
+ * Test for class initialization
+ */
+ @Test
+ public void testInitialization() {
+ MMapInput input = new MMapInput("sqoopsqoop", false);
+ assertEquals("sqoopsqoop", input.getName());
+ assertEquals(MInputType.MAP, input.getType());
+ }
+
+ /**
+ * Test for equals() method
+ */
+ @Test
+ public void testEquals() {
+ // Positive test
+ MMapInput input1 = new MMapInput("sqoopsqoop", false);
+ MMapInput input2 = new MMapInput("sqoopsqoop", false);
+ assertTrue(input1.equals(input2));
+
+ // Negative test
+ MMapInput input3 = new MMapInput("sqoopsqoop", false);
+ MMapInput input4 = new MMapInput("sqoopsqoop1", false);
+ assertFalse(input3.equals(input4));
+ }
+
+ /**
+ * Test for value
+ */
+ @Test
+ public void testValue() {
+ MMapInput input1 = new MMapInput("sqoopsqoop", false);
+ Map<String, String> map1 = new HashMap<String, String>();
+ input1.setValue(map1);
+ assertEquals(map1, input1.getValue());
+ input1.setEmpty();
+ assertNull(input1.getValue());
+ }
+
+ /**
+ * Test for getUrlSafeValueString() and restoreFromUrlSafeValueString()
+ */
+ @Test
+ public void testUrlSafe() {
+ MMapInput input1 = new MMapInput("sqoopsqoop", false);
+ Map<String, String> map1 = new HashMap<String, String>();
+ input1.setValue(map1);
+ // Getting URL safe string
+ String tmp = input1.getUrlSafeValueString();
+ // Restore to actual value
+ input1.restoreFromUrlSafeValueString(tmp);
+ assertNotNull(input1.getValue());
+ assertEquals(0, input1.getValue().size());
+
+ input1.setValue(null);
+ tmp = input1.getUrlSafeValueString();
+ input1.restoreFromUrlSafeValueString(tmp);
+ assertNull(input1.getValue());
+ }
+
+ /**
+ * Test case for MNamedElement.getLabelKey() and MNamedElement.getHelpKey()
+ */
+ @Test
+ public void testNamedElement() {
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ assertEquals("sqoopsqoop.label", input1.getLabelKey());
+ assertEquals("sqoopsqoop.help", input1.getHelpKey());
+ }
+
+ /**
+ * Test for sensitivity
+ */
+ @Test
+ public void testSensitivity() {
+ MMapInput input1 = new MMapInput("NAME", false);
+ MMapInput input2 = new MMapInput("NAME", true);
+ assertFalse(input1.isSensitive());
+ assertTrue(input2.isSensitive());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 4fcb212..f336bab 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
@@ -26,14 +26,14 @@ import org.junit.Test;
*/
public class TestMNamedElement {
-// /**
-// * Test initialization and values
-// */
-// @Test
-// public void testInitialization() {
-// MNamedElement named = new MIntegerInput("SQOOP", false);
-// assertEquals("SQOOP", named.getName());
-// assertEquals("SQOOP.label", named.getLabelKey());
-// assertEquals("SQOOP.help", named.getHelpKey());
-// }
+ /**
+ * Test initialization and values
+ */
+ @Test
+ public void testInitialization() {
+ MNamedElement named = new MIntegerInput("SQOOP", false);
+ assertEquals("SQOOP", named.getName());
+ assertEquals("SQOOP.label", named.getLabelKey());
+ assertEquals("SQOOP.help", named.getHelpKey());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/model/TestMPersistableEntity.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMPersistableEntity.java b/common/src/test/java/org/apache/sqoop/model/TestMPersistableEntity.java
index d68f06c..000c6be 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMPersistableEntity.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMPersistableEntity.java
@@ -22,28 +22,28 @@ import org.junit.Test;
public class TestMPersistableEntity {
-// @Test
-// public void testPersistableId() {
-// PersistentId id = new PersistentId();
-//
-// assertFalse(id.hasPersistenceId());
-//
-// id.setPersistenceId(666);
-// assertTrue(id.hasPersistenceId());
-// assertEquals(666, id.getPersistenceId());
-// }
-//
-// /**
-// * Testing class extending MPersistableEntity.
-// *
-// * Empty implementation with purpose to just test methods available
-// * directly in the abstract class.
-// */
-// public static class PersistentId extends MPersistableEntity {
-// @Override
-// public String toString() {
-// return null;
-// }
-// }
+ @Test
+ public void testPersistableId() {
+ PersistentId id = new PersistentId();
+
+ assertFalse(id.hasPersistenceId());
+
+ id.setPersistenceId(666);
+ assertTrue(id.hasPersistenceId());
+ assertEquals(666, id.getPersistenceId());
+ }
+
+ /**
+ * Testing class extending MPersistableEntity.
+ *
+ * Empty implementation with purpose to just test methods available
+ * directly in the abstract class.
+ */
+ public static class PersistentId extends MPersistableEntity {
+ @Override
+ public String toString() {
+ return null;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 b0223a7..2fe0335 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
@@ -26,70 +26,70 @@ import org.junit.Test;
*/
public class TestMStringInput {
-// /**
-// * Test for class initialization
-// */
-// @Test
-// public void testInitialization() {
-// short len = 6;
-// MStringInput input = new MStringInput("sqoopsqoop", true, len);
-// assertEquals("sqoopsqoop", input.getName());
-// assertEquals(true, input.isSensitive());
-// assertEquals(len, input.getMaxLength());
-// assertEquals(MInputType.STRING, input.getType());
-// }
-//
-// /**
-// * Test for equals() method
-// */
-// @Test
-// public void testEquals() {
-// short len = 6;
-// // Positive test
-// MStringInput input1 = new MStringInput("sqoopsqoop", true, len);
-// MStringInput input2 = new MStringInput("sqoopsqoop", true, len);
-// assertTrue(input1.equals(input2));
-//
-// // Negative test
-// MStringInput input3 = new MStringInput("sqoopsqoop", false, len);
-// MStringInput input4 = new MStringInput("sqoopsqoop", true, len);
-// assertFalse(input3.equals(input4));
-// }
-//
-// /**
-// * Test for value
-// */
-// @Test
-// public void testValue() {
-// MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
-// input1.setValue("sqoop");
-// assertEquals("sqoop", input1.getValue());
-// input1.setEmpty();
-// assertNull(input1.getValue());
-// }
-//
-// /**
-// * Test for getUrlSafeValueString() and restoreFromUrlSafeValueString()
-// */
-// @Test
-// public void testUrlSafe() {
-// MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
-// String s = "Sqoop%$!@#&*()Sqoop";
-// input1.setValue(s);
-// // Getting URL safe string
-// String tmp = input1.getUrlSafeValueString();
-// // Restore to actual value
-// input1.restoreFromUrlSafeValueString(tmp);
-// assertEquals(s, input1.getValue());
-// }
-//
-// /**
-// * Test case for MNamedElement.getLabelKey() and MNamedElement.getHelpKey()
-// */
-// @Test
-// public void testNamedElement() {
-// MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
-// assertEquals("sqoopsqoop.label", input1.getLabelKey());
-// assertEquals("sqoopsqoop.help", input1.getHelpKey());
-// }
+ /**
+ * Test for class initialization
+ */
+ @Test
+ public void testInitialization() {
+ short len = 6;
+ MStringInput input = new MStringInput("sqoopsqoop", true, len);
+ assertEquals("sqoopsqoop", input.getName());
+ assertEquals(true, input.isSensitive());
+ assertEquals(len, input.getMaxLength());
+ assertEquals(MInputType.STRING, input.getType());
+ }
+
+ /**
+ * Test for equals() method
+ */
+ @Test
+ public void testEquals() {
+ short len = 6;
+ // Positive test
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, len);
+ MStringInput input2 = new MStringInput("sqoopsqoop", true, len);
+ assertTrue(input1.equals(input2));
+
+ // Negative test
+ MStringInput input3 = new MStringInput("sqoopsqoop", false, len);
+ MStringInput input4 = new MStringInput("sqoopsqoop", true, len);
+ assertFalse(input3.equals(input4));
+ }
+
+ /**
+ * Test for value
+ */
+ @Test
+ public void testValue() {
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ input1.setValue("sqoop");
+ assertEquals("sqoop", input1.getValue());
+ input1.setEmpty();
+ assertNull(input1.getValue());
+ }
+
+ /**
+ * Test for getUrlSafeValueString() and restoreFromUrlSafeValueString()
+ */
+ @Test
+ public void testUrlSafe() {
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ String s = "Sqoop%$!@#&*()Sqoop";
+ input1.setValue(s);
+ // Getting URL safe string
+ String tmp = input1.getUrlSafeValueString();
+ // Restore to actual value
+ input1.restoreFromUrlSafeValueString(tmp);
+ assertEquals(s, input1.getValue());
+ }
+
+ /**
+ * Test case for MNamedElement.getLabelKey() and MNamedElement.getHelpKey()
+ */
+ @Test
+ public void testNamedElement() {
+ MStringInput input1 = new MStringInput("sqoopsqoop", true, (short) 5);
+ assertEquals("sqoopsqoop.label", input1.getLabelKey());
+ assertEquals("sqoopsqoop.help", input1.getHelpKey());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 7c9a3d9..3fd5a95 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
@@ -27,44 +27,44 @@ import org.junit.Test;
*/
public class TestMValidatedElement {
-// /**
-// * Test for initalization
-// */
-// @Test
-// public void testInitialization() {
-// MValidatedElement input = new MIntegerInput("input", false);
-// assertEquals("input", input.getName());
-// assertEquals(Status.FINE, input.getValidationStatus());
-// }
-//
-// /**
-// * Test for validation message and status
-// */
-// @Test
-// public void testValidationMessageStatus() {
-// MValidatedElement input = new MIntegerInput("input", false);
-// // Default status
-// assertEquals(Status.FINE, input.getValidationStatus());
-// // Set status and user message
-// input.setValidationMessage(Status.ACCEPTABLE, "MY_MESSAGE");
-// assertEquals(Status.ACCEPTABLE, input.getValidationStatus());
-// assertEquals("MY_MESSAGE", input.getValidationMessage());
-// // Check for null if status does not equal
-// assertNull(input.getValidationMessage(Status.FINE));
-// assertNull(input.getErrorMessage());
-// assertNotNull(input.getWarningMessage());
-// // Set unacceptable status
-// input.setValidationMessage(Status.UNACCEPTABLE, "MY_MESSAGE");
-// assertNotNull(input.getErrorMessage());
-// assertEquals("MY_MESSAGE", input.getErrorMessage());
-// assertNull(input.getWarningMessage());
-// // Set warning
-// input.setWarningMessage("WARN");
-// assertEquals(Status.ACCEPTABLE, input.getValidationStatus());
-// assertEquals("WARN", input.getValidationMessage());
-// // Unacceptable method
-// input.setErrorMessage("ERROR");
-// assertEquals(Status.UNACCEPTABLE, input.getValidationStatus());
-// assertEquals("ERROR", input.getValidationMessage());
-// }
+ /**
+ * Test for initalization
+ */
+ @Test
+ public void testInitialization() {
+ MValidatedElement input = new MIntegerInput("input", false);
+ assertEquals("input", input.getName());
+ assertEquals(Status.FINE, input.getValidationStatus());
+ }
+
+ /**
+ * Test for validation message and status
+ */
+ @Test
+ public void testValidationMessageStatus() {
+ MValidatedElement input = new MIntegerInput("input", false);
+ // Default status
+ assertEquals(Status.FINE, input.getValidationStatus());
+ // Set status and user message
+ input.setValidationMessage(Status.ACCEPTABLE, "MY_MESSAGE");
+ assertEquals(Status.ACCEPTABLE, input.getValidationStatus());
+ assertEquals("MY_MESSAGE", input.getValidationMessage());
+ // Check for null if status does not equal
+ assertNull(input.getValidationMessage(Status.FINE));
+ assertNull(input.getErrorMessage());
+ assertNotNull(input.getWarningMessage());
+ // Set unacceptable status
+ input.setValidationMessage(Status.UNACCEPTABLE, "MY_MESSAGE");
+ assertNotNull(input.getErrorMessage());
+ assertEquals("MY_MESSAGE", input.getErrorMessage());
+ assertNull(input.getWarningMessage());
+ // Set warning
+ input.setWarningMessage("WARN");
+ assertEquals(Status.ACCEPTABLE, input.getValidationStatus());
+ assertEquals("WARN", input.getValidationMessage());
+ // Unacceptable method
+ input.setErrorMessage("ERROR");
+ assertEquals(Status.UNACCEPTABLE, input.getValidationStatus());
+ assertEquals("ERROR", input.getValidationMessage());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/submission/TestSubmissionStatus.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/submission/TestSubmissionStatus.java b/common/src/test/java/org/apache/sqoop/submission/TestSubmissionStatus.java
index 5d6692d..99f4767 100644
--- a/common/src/test/java/org/apache/sqoop/submission/TestSubmissionStatus.java
+++ b/common/src/test/java/org/apache/sqoop/submission/TestSubmissionStatus.java
@@ -27,38 +27,38 @@ import junit.framework.TestCase;
*/
public class TestSubmissionStatus extends TestCase {
-// /**
-// * unfinished() test
-// */
-// public void testUnfinished() {
-// SubmissionStatus subStatus[] = SubmissionStatus.unfinished();
-// SubmissionStatus subStatusTest[] = new SubmissionStatus[] {
-// SubmissionStatus.RUNNING, SubmissionStatus.BOOTING };
-// List<SubmissionStatus> tempSubmissionStatusList = Arrays.asList(subStatus);
-// for (SubmissionStatus stat : subStatusTest) {
-// assertTrue(tempSubmissionStatusList.contains(stat));
-// }
-// }
-//
-// /**
-// * isRunning() test
-// */
-// public void testIsRunning() {
-// assertTrue(SubmissionStatus.RUNNING.isRunning());
-// assertTrue(SubmissionStatus.BOOTING.isRunning());
-// assertFalse(SubmissionStatus.FAILED.isRunning());
-// assertFalse(SubmissionStatus.UNKNOWN.isRunning());
-// assertFalse(SubmissionStatus.FAILURE_ON_SUBMIT.isRunning());
-// }
-//
-// /**
-// * isFailure() test
-// */
-// public void testIsFailure() {
-// assertTrue(SubmissionStatus.FAILED.isFailure());
-// assertTrue(SubmissionStatus.UNKNOWN.isFailure());
-// assertTrue(SubmissionStatus.FAILURE_ON_SUBMIT.isFailure());
-// assertFalse(SubmissionStatus.RUNNING.isFailure());
-// assertFalse(SubmissionStatus.BOOTING.isFailure());
-// }
+ /**
+ * unfinished() test
+ */
+ public void testUnfinished() {
+ SubmissionStatus subStatus[] = SubmissionStatus.unfinished();
+ SubmissionStatus subStatusTest[] = new SubmissionStatus[] {
+ SubmissionStatus.RUNNING, SubmissionStatus.BOOTING };
+ List<SubmissionStatus> tempSubmissionStatusList = Arrays.asList(subStatus);
+ for (SubmissionStatus stat : subStatusTest) {
+ assertTrue(tempSubmissionStatusList.contains(stat));
+ }
+ }
+
+ /**
+ * isRunning() test
+ */
+ public void testIsRunning() {
+ assertTrue(SubmissionStatus.RUNNING.isRunning());
+ assertTrue(SubmissionStatus.BOOTING.isRunning());
+ assertFalse(SubmissionStatus.FAILED.isRunning());
+ assertFalse(SubmissionStatus.UNKNOWN.isRunning());
+ assertFalse(SubmissionStatus.FAILURE_ON_SUBMIT.isRunning());
+ }
+
+ /**
+ * isFailure() test
+ */
+ public void testIsFailure() {
+ assertTrue(SubmissionStatus.FAILED.isFailure());
+ assertTrue(SubmissionStatus.UNKNOWN.isFailure());
+ assertTrue(SubmissionStatus.FAILURE_ON_SUBMIT.isFailure());
+ assertFalse(SubmissionStatus.RUNNING.isFailure());
+ assertFalse(SubmissionStatus.BOOTING.isFailure());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/submission/counter/TestCounter.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/submission/counter/TestCounter.java b/common/src/test/java/org/apache/sqoop/submission/counter/TestCounter.java
index 962a535..0cf5d2b 100644
--- a/common/src/test/java/org/apache/sqoop/submission/counter/TestCounter.java
+++ b/common/src/test/java/org/apache/sqoop/submission/counter/TestCounter.java
@@ -25,20 +25,20 @@ import org.junit.Test;
*/
public class TestCounter {
-// /**
-// * Test method for initialization
-// */
-// @Test
-// public void testInitialization() {
-// Counter counter = new Counter("sqoop");
-// Assert.assertEquals("sqoop", counter.getName());
-// Assert.assertEquals(0l, counter.getValue());
-//
-// Counter counter1 = new Counter("sqoop", 1000l);
-// Assert.assertEquals("sqoop", counter1.getName());
-// Assert.assertEquals(1000l, counter1.getValue());
-//
-// counter1.setValue(2000l);
-// Assert.assertEquals(2000l, counter1.getValue());
-// }
+ /**
+ * Test method for initialization
+ */
+ @Test
+ public void testInitialization() {
+ Counter counter = new Counter("sqoop");
+ Assert.assertEquals("sqoop", counter.getName());
+ Assert.assertEquals(0l, counter.getValue());
+
+ Counter counter1 = new Counter("sqoop", 1000l);
+ Assert.assertEquals("sqoop", counter1.getName());
+ Assert.assertEquals(1000l, counter1.getValue());
+
+ counter1.setValue(2000l);
+ Assert.assertEquals(2000l, counter1.getValue());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/submission/counter/TestCounterGroup.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/submission/counter/TestCounterGroup.java b/common/src/test/java/org/apache/sqoop/submission/counter/TestCounterGroup.java
index aac80d4..985009a 100644
--- a/common/src/test/java/org/apache/sqoop/submission/counter/TestCounterGroup.java
+++ b/common/src/test/java/org/apache/sqoop/submission/counter/TestCounterGroup.java
@@ -26,56 +26,56 @@ import org.junit.Test;
*/
public class TestCounterGroup {
-// /**
-// * CounterGroup initialization
-// */
-// @Test
-// public void testInitialization() {
-// CounterGroup cg = new CounterGroup("sqoop");
-// Assert.assertEquals("sqoop", cg.getName());
-// Assert.assertFalse(cg.iterator().hasNext());
-//
-// Counter c1 = new Counter("counter");
-// cg.addCounter(c1);
-// }
-//
-// /**
-// * Test for add and get counter
-// */
-// @Test
-// public void testAddGetCounter() {
-// CounterGroup cg = new CounterGroup("sqoop");
-// Counter c1 = new Counter("counter");
-// cg.addCounter(c1);
-// Assert.assertNotNull(cg.getCounter("counter"));
-// Assert.assertNull(cg.getCounter("NA"));
-// }
-//
-// /**
-// * Test for iterator
-// */
-// @Test
-// public void testIterator() {
-// CounterGroup cg = new CounterGroup("sqoop");
-// Counter c1 = new Counter("counter1");
-// Counter c2 = new Counter("counter2");
-// // Adding 2 Counter into CounterGroup
-// cg.addCounter(c1);
-// cg.addCounter(c2);
-// int count = 0;
-//
-// for (Counter c : cg) {
-// count++;
-// }
-// Assert.assertEquals(2, count);
-//
-// Counter c3 = new Counter("counter3");
-// cg.addCounter(c3);
-// count = 0;
-//
-// for (Counter c : cg) {
-// count++;
-// }
-// Assert.assertEquals(3, count);
-// }
+ /**
+ * CounterGroup initialization
+ */
+ @Test
+ public void testInitialization() {
+ CounterGroup cg = new CounterGroup("sqoop");
+ Assert.assertEquals("sqoop", cg.getName());
+ Assert.assertFalse(cg.iterator().hasNext());
+
+ Counter c1 = new Counter("counter");
+ cg.addCounter(c1);
+ }
+
+ /**
+ * Test for add and get counter
+ */
+ @Test
+ public void testAddGetCounter() {
+ CounterGroup cg = new CounterGroup("sqoop");
+ Counter c1 = new Counter("counter");
+ cg.addCounter(c1);
+ Assert.assertNotNull(cg.getCounter("counter"));
+ Assert.assertNull(cg.getCounter("NA"));
+ }
+
+ /**
+ * Test for iterator
+ */
+ @Test
+ public void testIterator() {
+ CounterGroup cg = new CounterGroup("sqoop");
+ Counter c1 = new Counter("counter1");
+ Counter c2 = new Counter("counter2");
+ // Adding 2 Counter into CounterGroup
+ cg.addCounter(c1);
+ cg.addCounter(c2);
+ int count = 0;
+
+ for (Counter c : cg) {
+ count++;
+ }
+ Assert.assertEquals(2, count);
+
+ Counter c3 = new Counter("counter3");
+ cg.addCounter(c3);
+ count = 0;
+
+ for (Counter c : cg) {
+ count++;
+ }
+ Assert.assertEquals(3, count);
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/submission/counter/TestCounters.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/submission/counter/TestCounters.java b/common/src/test/java/org/apache/sqoop/submission/counter/TestCounters.java
index 22839c9..8f8d617 100644
--- a/common/src/test/java/org/apache/sqoop/submission/counter/TestCounters.java
+++ b/common/src/test/java/org/apache/sqoop/submission/counter/TestCounters.java
@@ -26,42 +26,42 @@ import junit.framework.Assert;
*/
public class TestCounters {
-// /**
-// * Test initialization
-// */
-// @Test
-// public void testInitialization() {
-// Counters counters = new Counters();
-// Assert.assertTrue(counters.isEmpty());
-// }
-//
-// /**
-// * Test add and get CountersGroup
-// */
-// @Test
-// public void testAddGetCounters() {
-// Counters counters = new Counters();
-// CounterGroup cg = new CounterGroup("sqoop");
-// counters.addCounterGroup(cg);
-// Assert.assertFalse(counters.isEmpty());
-// Assert.assertNotNull(counters.getCounterGroup("sqoop"));
-// Assert.assertEquals("sqoop", counters.getCounterGroup("sqoop").getName());
-// }
-//
-// /**
-// * Test for iterator
-// */
-// @Test
-// public void testIterator() {
-// Counters counters = new Counters();
-// CounterGroup cg1 = new CounterGroup("sqoop1");
-// CounterGroup cg2 = new CounterGroup("sqoop2");
-// counters.addCounterGroup(cg1);
-// counters.addCounterGroup(cg2);
-// int count = 0;
-// for (CounterGroup cg : counters) {
-// count++;
-// }
-// Assert.assertEquals(2, count);
-// }
+ /**
+ * Test initialization
+ */
+ @Test
+ public void testInitialization() {
+ Counters counters = new Counters();
+ Assert.assertTrue(counters.isEmpty());
+ }
+
+ /**
+ * Test add and get CountersGroup
+ */
+ @Test
+ public void testAddGetCounters() {
+ Counters counters = new Counters();
+ CounterGroup cg = new CounterGroup("sqoop");
+ counters.addCounterGroup(cg);
+ Assert.assertFalse(counters.isEmpty());
+ Assert.assertNotNull(counters.getCounterGroup("sqoop"));
+ Assert.assertEquals("sqoop", counters.getCounterGroup("sqoop").getName());
+ }
+
+ /**
+ * Test for iterator
+ */
+ @Test
+ public void testIterator() {
+ Counters counters = new Counters();
+ CounterGroup cg1 = new CounterGroup("sqoop1");
+ CounterGroup cg2 = new CounterGroup("sqoop2");
+ counters.addCounterGroup(cg1);
+ counters.addCounterGroup(cg2);
+ int count = 0;
+ for (CounterGroup cg : counters) {
+ count++;
+ }
+ Assert.assertEquals(2, count);
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/utils/TestMapResourceBundle.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/utils/TestMapResourceBundle.java b/common/src/test/java/org/apache/sqoop/utils/TestMapResourceBundle.java
index 88fe058..1edc404 100644
--- a/common/src/test/java/org/apache/sqoop/utils/TestMapResourceBundle.java
+++ b/common/src/test/java/org/apache/sqoop/utils/TestMapResourceBundle.java
@@ -28,14 +28,14 @@ import static org.junit.Assert.*;
*
*/
public class TestMapResourceBundle {
-// @Test
-// public void testUsage() {
-// Map<String, Object> map = new HashMap<String, Object>();
-// map.put("a", "1");
-// map.put("b", "2");
-//
-// MapResourceBundle bundle = new MapResourceBundle(map);
-// assertEquals("1", bundle.getString("a"));
-// assertEquals("2", bundle.getString("b"));
-// }
+ @Test
+ public void testUsage() {
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("a", "1");
+ map.put("b", "2");
+
+ MapResourceBundle bundle = new MapResourceBundle(map);
+ assertEquals("1", bundle.getString("a"));
+ assertEquals("2", bundle.getString("b"));
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/validation/TestStatus.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/validation/TestStatus.java b/common/src/test/java/org/apache/sqoop/validation/TestStatus.java
index 654a024..5b17a4e 100644
--- a/common/src/test/java/org/apache/sqoop/validation/TestStatus.java
+++ b/common/src/test/java/org/apache/sqoop/validation/TestStatus.java
@@ -25,29 +25,29 @@ import static junit.framework.Assert.*;
*
*/
public class TestStatus {
-// @Test
-// public void testGetWorstStatus() {
-// // Comparing itself with itself
-// assertEquals(Status.FINE,
-// Status.getWorstStatus(Status.FINE));
-// assertEquals(Status.FINE,
-// Status.getWorstStatus(Status.FINE, Status.FINE));
-// assertEquals(Status.ACCEPTABLE,
-// Status.getWorstStatus(Status.ACCEPTABLE, Status.ACCEPTABLE));
-// assertEquals(Status.UNACCEPTABLE,
-// Status.getWorstStatus(Status.UNACCEPTABLE, Status.UNACCEPTABLE));
-//
-// // Retriving the worst option
-// assertEquals(Status.UNACCEPTABLE,
-// Status.getWorstStatus(Status.FINE, Status.UNACCEPTABLE));
-// assertEquals(Status.ACCEPTABLE,
-// Status.getWorstStatus(Status.FINE, Status.ACCEPTABLE));
-// }
-//
-// @Test
-// public void testCanProceed() {
-// assertTrue(Status.FINE.canProceed());
-// assertTrue(Status.ACCEPTABLE.canProceed());
-// assertFalse(Status.UNACCEPTABLE.canProceed());
-// }
+ @Test
+ public void testGetWorstStatus() {
+ // Comparing itself with itself
+ assertEquals(Status.FINE,
+ Status.getWorstStatus(Status.FINE));
+ assertEquals(Status.FINE,
+ Status.getWorstStatus(Status.FINE, Status.FINE));
+ assertEquals(Status.ACCEPTABLE,
+ Status.getWorstStatus(Status.ACCEPTABLE, Status.ACCEPTABLE));
+ assertEquals(Status.UNACCEPTABLE,
+ Status.getWorstStatus(Status.UNACCEPTABLE, Status.UNACCEPTABLE));
+
+ // Retriving the worst option
+ assertEquals(Status.UNACCEPTABLE,
+ Status.getWorstStatus(Status.FINE, Status.UNACCEPTABLE));
+ assertEquals(Status.ACCEPTABLE,
+ Status.getWorstStatus(Status.FINE, Status.ACCEPTABLE));
+ }
+
+ @Test
+ public void testCanProceed() {
+ assertTrue(Status.FINE.canProceed());
+ assertTrue(Status.ACCEPTABLE.canProceed());
+ assertFalse(Status.UNACCEPTABLE.canProceed());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/validation/TestValidation.java b/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
index be6ee84..bf0ade5 100644
--- a/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
+++ b/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
@@ -31,113 +31,113 @@ import org.apache.sqoop.validation.Validation.Message;
*/
public class TestValidation extends TestCase {
-// /**
-// * Initialization test
-// */
-// public void testInitialization() {
-// /* Check initialization with class */
-// Validation validation = new Validation(Class.class);
-// assertNotNull(validation);
-// assertEquals(Status.FINE, validation.getStatus());
-// assertEquals(0, validation.getMessages().size());
-//
-// /* Check initialization with status and message as null */
-// Validation validationNull = new Validation(null, null);
-// assertNotNull(validationNull);
-// assertNull(validationNull.getStatus());
-// assertNull(validationNull.getMessages());
-//
-// /* Check initialization with status and message with values */
-// Status s1 = Status.FINE;
-// Map<FormInput, Message> msg1 = new HashMap<Validation.FormInput, Validation.Message>();
-// Validation validation1 = new Validation(s1, msg1);
-// assertNotNull(validation1);
-// assertEquals(Status.FINE, validation1.getStatus());
-// assertEquals(0, validation1.getMessages().size());
-//
-// /* Check initialization with status and message with values */
-// Status s2 = Status.ACCEPTABLE;
-// Map<FormInput, Message> msg2 = new HashMap<Validation.FormInput, Validation.Message>();
-// Validation validation2 = new Validation(s2, msg2);
-// assertNotNull(validation2);
-// assertEquals(Status.ACCEPTABLE, validation2.getStatus());
-// assertEquals(0, validation2.getMessages().size());
-//
-// /* Check initialization with status and message with values */
-// Status s3 = Status.ACCEPTABLE;
-// Map<FormInput, Message> msg3 = new HashMap<Validation.FormInput, Validation.Message>();
-// Validation.FormInput fi = new Validation.FormInput("form\\.input");
-// Validation.Message message = new Validation.Message(Status.FINE, "sqoop");
-// msg3.put(fi, message);
-// Validation validation3 = new Validation(s3, msg3);
-// Validation.FormInput fiTest = new Validation.FormInput("form\\.input");
-// Validation.Message messageTest = new Validation.Message(Status.FINE,
-// "sqoop");
-// assertEquals(messageTest, validation3.getMessages().get(fiTest));
-// assertEquals(Status.ACCEPTABLE, validation3.getStatus());
-// }
-//
-// /**
-// * Test for Validation.ForInput
-// */
-// public void testFormInput() {
-// Validation.FormInput fi = new Validation.FormInput("test\\.test");
-// assertNotNull(fi);
-//
-// /* Passing null */
-// try {
-// new Validation.FormInput(null);
-// fail("Assert error is expected");
-// } catch (AssertionError e) {
-// assertTrue(true);
-// }
-//
-// /* Passing empty and check exception messages */
-// try {
-// new Validation.FormInput("");
-// fail("SqoopException is expected");
-// } catch (SqoopException e) {
-// assertEquals(ValidationError.VALIDATION_0003.getMessage(), e
-// .getErrorCode().getMessage());
-// }
-//
-// /* Passing value and check */
-// Validation.FormInput fi2 = new Validation.FormInput("form\\.input");
-// assertEquals("form\\", fi2.getForm());
-// assertEquals("input", fi2.getInput());
-//
-// /* Check equals */
-// Validation.FormInput fiOne = new Validation.FormInput("form\\.input");
-// Validation.FormInput fiTwo = new Validation.FormInput("form\\.input");
-// assertEquals(fiOne, fiTwo);
-//
-// /* toString() method check */
-// assertEquals("form\\.input", fiOne.toString());
-//
-// // Checking null as input field (form validation)
-// Validation.FormInput fi3 = new FormInput("form");
-// assertEquals("form", fi3.getForm());
-// assertNull(fi3.getInput());
-// assertEquals("form", fi3.toString());
-//
-// }
-//
-// /**
-// * Test for Validation.Message
-// */
-// public void testMessage() {
-// /* Passing null */
-// Validation.Message msg1 = new Validation.Message(null, null);
-// assertNull(msg1.getStatus());
-// assertNull(msg1.getMessage());
-//
-// /* Passing values */
-// Validation.Message msg2 = new Validation.Message(Status.FINE, "sqoop");
-// assertEquals(Status.FINE, msg2.getStatus());
-// assertEquals("sqoop", msg2.getMessage());
-//
-// /* Check for equal */
-// Validation.Message msg3 = new Validation.Message(Status.FINE, "sqoop");
-// assertEquals(msg2, msg3);
-// }
+ /**
+ * Initialization test
+ */
+ public void testInitialization() {
+ /* Check initialization with class */
+ Validation validation = new Validation(Class.class);
+ assertNotNull(validation);
+ assertEquals(Status.FINE, validation.getStatus());
+ assertEquals(0, validation.getMessages().size());
+
+ /* Check initialization with status and message as null */
+ Validation validationNull = new Validation(null, null);
+ assertNotNull(validationNull);
+ assertNull(validationNull.getStatus());
+ assertNull(validationNull.getMessages());
+
+ /* Check initialization with status and message with values */
+ Status s1 = Status.FINE;
+ Map<FormInput, Message> msg1 = new HashMap<Validation.FormInput, Validation.Message>();
+ Validation validation1 = new Validation(s1, msg1);
+ assertNotNull(validation1);
+ assertEquals(Status.FINE, validation1.getStatus());
+ assertEquals(0, validation1.getMessages().size());
+
+ /* Check initialization with status and message with values */
+ Status s2 = Status.ACCEPTABLE;
+ Map<FormInput, Message> msg2 = new HashMap<Validation.FormInput, Validation.Message>();
+ Validation validation2 = new Validation(s2, msg2);
+ assertNotNull(validation2);
+ assertEquals(Status.ACCEPTABLE, validation2.getStatus());
+ assertEquals(0, validation2.getMessages().size());
+
+ /* Check initialization with status and message with values */
+ Status s3 = Status.ACCEPTABLE;
+ Map<FormInput, Message> msg3 = new HashMap<Validation.FormInput, Validation.Message>();
+ Validation.FormInput fi = new Validation.FormInput("form\\.input");
+ Validation.Message message = new Validation.Message(Status.FINE, "sqoop");
+ msg3.put(fi, message);
+ Validation validation3 = new Validation(s3, msg3);
+ Validation.FormInput fiTest = new Validation.FormInput("form\\.input");
+ Validation.Message messageTest = new Validation.Message(Status.FINE,
+ "sqoop");
+ assertEquals(messageTest, validation3.getMessages().get(fiTest));
+ assertEquals(Status.ACCEPTABLE, validation3.getStatus());
+ }
+
+ /**
+ * Test for Validation.ForInput
+ */
+ public void testFormInput() {
+ Validation.FormInput fi = new Validation.FormInput("test\\.test");
+ assertNotNull(fi);
+
+ /* Passing null */
+ try {
+ new Validation.FormInput(null);
+ fail("Assert error is expected");
+ } catch (AssertionError e) {
+ assertTrue(true);
+ }
+
+ /* Passing empty and check exception messages */
+ try {
+ new Validation.FormInput("");
+ fail("SqoopException is expected");
+ } catch (SqoopException e) {
+ assertEquals(ValidationError.VALIDATION_0003.getMessage(), e
+ .getErrorCode().getMessage());
+ }
+
+ /* Passing value and check */
+ Validation.FormInput fi2 = new Validation.FormInput("form\\.input");
+ assertEquals("form\\", fi2.getForm());
+ assertEquals("input", fi2.getInput());
+
+ /* Check equals */
+ Validation.FormInput fiOne = new Validation.FormInput("form\\.input");
+ Validation.FormInput fiTwo = new Validation.FormInput("form\\.input");
+ assertEquals(fiOne, fiTwo);
+
+ /* toString() method check */
+ assertEquals("form\\.input", fiOne.toString());
+
+ // Checking null as input field (form validation)
+ Validation.FormInput fi3 = new FormInput("form");
+ assertEquals("form", fi3.getForm());
+ assertNull(fi3.getInput());
+ assertEquals("form", fi3.toString());
+
+ }
+
+ /**
+ * Test for Validation.Message
+ */
+ public void testMessage() {
+ /* Passing null */
+ Validation.Message msg1 = new Validation.Message(null, null);
+ assertNull(msg1.getStatus());
+ assertNull(msg1.getMessage());
+
+ /* Passing values */
+ Validation.Message msg2 = new Validation.Message(Status.FINE, "sqoop");
+ assertEquals(Status.FINE, msg2.getStatus());
+ assertEquals("sqoop", msg2.getMessage());
+
+ /* Check for equal */
+ Validation.Message msg3 = new Validation.Message(Status.FINE, "sqoop");
+ assertEquals(msg2, msg3);
+ }
}
[2/2] git commit: SQOOP-1449: Sqoop2: From/To: Re-enable common tests
Posted by ja...@apache.org.
SQOOP-1449: Sqoop2: From/To: Re-enable common tests
(Abraham Elmahrek 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/3bb7ff83
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/3bb7ff83
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/3bb7ff83
Branch: refs/heads/SQOOP-1367
Commit: 3bb7ff834123f74dd650a57597a59c4854479f0d
Parents: 5f04f53
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Tue Aug 19 13:42:50 2014 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Tue Aug 19 13:42:50 2014 -0700
----------------------------------------------------------------------
.../org/apache/sqoop/common/TestMapContext.java | 156 +++----
.../sqoop/common/TestSqoopResponseCode.java | 26 +-
.../apache/sqoop/common/TestVersionInfo.java | 16 +-
.../apache/sqoop/json/TestConnectionBean.java | 202 ++++-----
.../apache/sqoop/json/TestConnectorBean.java | 72 ++--
.../apache/sqoop/json/TestFrameworkBean.java | 52 +--
.../java/org/apache/sqoop/json/TestJobBean.java | 116 ++---
.../org/apache/sqoop/json/TestSchemaBean.java | 40 +-
.../java/org/apache/sqoop/json/TestUtil.java | 216 +++++-----
.../apache/sqoop/json/TestValidationBean.java | 212 +++++----
.../sqoop/json/util/TestFormSerialization.java | 224 +++++-----
.../json/util/TestSchemaSerialization.java | 262 ++++++------
.../org/apache/sqoop/model/TestFormUtils.java | 428 +++++++++----------
.../sqoop/model/TestMAccountableEntity.java | 56 +--
.../apache/sqoop/model/TestMBooleanInput.java | 132 +++---
.../org/apache/sqoop/model/TestMConnection.java | 178 ++++----
.../sqoop/model/TestMConnectionForms.java | 32 +-
.../org/apache/sqoop/model/TestMConnector.java | 72 ++--
.../org/apache/sqoop/model/TestMEnumInput.java | 68 +--
.../java/org/apache/sqoop/model/TestMForm.java | 114 ++---
.../org/apache/sqoop/model/TestMFormList.java | 52 +--
.../org/apache/sqoop/model/TestMFramework.java | 29 +-
.../apache/sqoop/model/TestMIntegerInput.java | 144 +++----
.../java/org/apache/sqoop/model/TestMJob.java | 213 ++++-----
.../org/apache/sqoop/model/TestMJobForms.java | 31 +-
.../org/apache/sqoop/model/TestMMapInput.java | 160 +++----
.../apache/sqoop/model/TestMNamedElement.java | 20 +-
.../sqoop/model/TestMPersistableEntity.java | 46 +-
.../apache/sqoop/model/TestMStringInput.java | 132 +++---
.../sqoop/model/TestMValidatedElement.java | 80 ++--
.../sqoop/submission/TestSubmissionStatus.java | 68 +--
.../sqoop/submission/counter/TestCounter.java | 32 +-
.../submission/counter/TestCounterGroup.java | 104 ++---
.../sqoop/submission/counter/TestCounters.java | 76 ++--
.../sqoop/utils/TestMapResourceBundle.java | 20 +-
.../org/apache/sqoop/validation/TestStatus.java | 50 +--
.../apache/sqoop/validation/TestValidation.java | 218 +++++-----
37 files changed, 2113 insertions(+), 2036 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/common/TestMapContext.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/common/TestMapContext.java b/common/src/test/java/org/apache/sqoop/common/TestMapContext.java
index 4c229ae..f4718c0 100644
--- a/common/src/test/java/org/apache/sqoop/common/TestMapContext.java
+++ b/common/src/test/java/org/apache/sqoop/common/TestMapContext.java
@@ -29,82 +29,82 @@ import org.junit.Test;
*/
public class TestMapContext {
-// /**
-// * Test method for Initialization
-// */
-// @Test
-// public void testInitalization() {
-// Map<String, String> options = new HashMap<String, String>();
-// options.put("testkey", "testvalue");
-// MapContext mc = new MapContext(options);
-// Assert.assertEquals("testvalue", mc.getString("testkey"));
-// }
-//
-// /**
-// * Test method for getString
-// */
-// @Test
-// public void testGetString() {
-// Map<String, String> options = new HashMap<String, String>();
-// options.put("testkey", "testvalue");
-// MapContext mc = new MapContext(options);
-// Assert.assertEquals("testvalue", mc.getString("testkey", "defaultValue"));
-// Assert.assertEquals("defaultValue",
-// mc.getString("wrongKey", "defaultValue"));
-// }
-//
-// /**
-// * Test method for getString with default value
-// */
-// @Test
-// public void testGetBoolean() {
-// Map<String, String> options = new HashMap<String, String>();
-// options.put("testkey", "true");
-// MapContext mc = new MapContext(options);
-// Assert.assertEquals(true, mc.getBoolean("testkey", false));
-// Assert.assertEquals(false, mc.getBoolean("wrongKey", false));
-// }
-//
-// /**
-// * Test method for getInt with default value
-// */
-// @Test
-// public void testGetInt() {
-// Map<String, String> options = new HashMap<String, String>();
-// options.put("testkey", "123");
-// MapContext mc = new MapContext(options);
-// Assert.assertEquals(123, mc.getInt("testkey", 456));
-// Assert.assertEquals(456, mc.getInt("wrongKey", 456));
-// }
-//
-// /**
-// * Test method for getLong with default value
-// */
-// @Test
-// public void testGetLong() {
-// Map<String, String> options = new HashMap<String, String>();
-// options.put("testkey", "123");
-// MapContext mc = new MapContext(options);
-// Assert.assertEquals(123l, mc.getLong("testkey", 456l));
-// Assert.assertEquals(456l, mc.getLong("wrongKey", 456l));
-// }
-//
-// /**
-// * Test method for getNestedProperties()
-// */
-// @Test
-// public void testGetNestedProperties() {
-// Map<String, String> options = new HashMap<String, String>();
-// options.put("sqooptest1", "value");
-// options.put("sqooptest2", "value");
-// options.put("testsqoop1", "value");
-// options.put("testsqoop1", "value");
-// MapContext mc = new MapContext(options);
-// Map<String, String> result = mc.getNestedProperties("sqoop");
-// Assert.assertEquals(2, result.size());
-// Assert.assertTrue(result.containsKey("test1"));
-// Assert.assertTrue(result.containsKey("test2"));
-// Assert.assertFalse(result.containsKey("testsqoop1"));
-// Assert.assertFalse(result.containsKey("testsqoop2"));
-// }
+ /**
+ * Test method for Initialization
+ */
+ @Test
+ public void testInitalization() {
+ Map<String, String> options = new HashMap<String, String>();
+ options.put("testkey", "testvalue");
+ MapContext mc = new MapContext(options);
+ Assert.assertEquals("testvalue", mc.getString("testkey"));
+ }
+
+ /**
+ * Test method for getString
+ */
+ @Test
+ public void testGetString() {
+ Map<String, String> options = new HashMap<String, String>();
+ options.put("testkey", "testvalue");
+ MapContext mc = new MapContext(options);
+ Assert.assertEquals("testvalue", mc.getString("testkey", "defaultValue"));
+ Assert.assertEquals("defaultValue",
+ mc.getString("wrongKey", "defaultValue"));
+ }
+
+ /**
+ * Test method for getString with default value
+ */
+ @Test
+ public void testGetBoolean() {
+ Map<String, String> options = new HashMap<String, String>();
+ options.put("testkey", "true");
+ MapContext mc = new MapContext(options);
+ Assert.assertEquals(true, mc.getBoolean("testkey", false));
+ Assert.assertEquals(false, mc.getBoolean("wrongKey", false));
+ }
+
+ /**
+ * Test method for getInt with default value
+ */
+ @Test
+ public void testGetInt() {
+ Map<String, String> options = new HashMap<String, String>();
+ options.put("testkey", "123");
+ MapContext mc = new MapContext(options);
+ Assert.assertEquals(123, mc.getInt("testkey", 456));
+ Assert.assertEquals(456, mc.getInt("wrongKey", 456));
+ }
+
+ /**
+ * Test method for getLong with default value
+ */
+ @Test
+ public void testGetLong() {
+ Map<String, String> options = new HashMap<String, String>();
+ options.put("testkey", "123");
+ MapContext mc = new MapContext(options);
+ Assert.assertEquals(123l, mc.getLong("testkey", 456l));
+ Assert.assertEquals(456l, mc.getLong("wrongKey", 456l));
+ }
+
+ /**
+ * Test method for getNestedProperties()
+ */
+ @Test
+ public void testGetNestedProperties() {
+ Map<String, String> options = new HashMap<String, String>();
+ options.put("sqooptest1", "value");
+ options.put("sqooptest2", "value");
+ options.put("testsqoop1", "value");
+ options.put("testsqoop1", "value");
+ MapContext mc = new MapContext(options);
+ Map<String, String> result = mc.getNestedProperties("sqoop");
+ Assert.assertEquals(2, result.size());
+ Assert.assertTrue(result.containsKey("test1"));
+ Assert.assertTrue(result.containsKey("test2"));
+ Assert.assertFalse(result.containsKey("testsqoop1"));
+ Assert.assertFalse(result.containsKey("testsqoop2"));
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/common/TestSqoopResponseCode.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/common/TestSqoopResponseCode.java b/common/src/test/java/org/apache/sqoop/common/TestSqoopResponseCode.java
index d8aa1d5..f556c1c 100644
--- a/common/src/test/java/org/apache/sqoop/common/TestSqoopResponseCode.java
+++ b/common/src/test/java/org/apache/sqoop/common/TestSqoopResponseCode.java
@@ -25,17 +25,17 @@ import org.junit.Test;
*/
public class TestSqoopResponseCode {
-// /**
-// * Test for the method getFromCode()
-// */
-// @Test
-// public void testGetFromCode() {
-// SqoopResponseCode src = SqoopResponseCode.getFromCode("1000");
-// Assert.assertEquals("OK", src.getMessage());
-// Assert.assertEquals("1000", src.getCode());
-//
-// SqoopResponseCode src1 = SqoopResponseCode.getFromCode("2000");
-// Assert.assertEquals("ERROR", src1.getMessage());
-// Assert.assertEquals("2000", src1.getCode());
-// }
+ /**
+ * Test for the method getFromCode()
+ */
+ @Test
+ public void testGetFromCode() {
+ SqoopResponseCode src = SqoopResponseCode.getFromCode("1000");
+ Assert.assertEquals("OK", src.getMessage());
+ Assert.assertEquals("1000", src.getCode());
+
+ SqoopResponseCode src1 = SqoopResponseCode.getFromCode("2000");
+ Assert.assertEquals("ERROR", src1.getMessage());
+ Assert.assertEquals("2000", src1.getCode());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/common/TestVersionInfo.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/common/TestVersionInfo.java b/common/src/test/java/org/apache/sqoop/common/TestVersionInfo.java
index f853af0..27d78f4 100644
--- a/common/src/test/java/org/apache/sqoop/common/TestVersionInfo.java
+++ b/common/src/test/java/org/apache/sqoop/common/TestVersionInfo.java
@@ -22,13 +22,13 @@ import org.junit.Test;
public class TestVersionInfo {
-// @Test
-// public void testValues() throws Exception {
-// Assert.assertNotSame("Unknown", VersionInfo.getVersion());
-// Assert.assertNotSame("Unknown", VersionInfo.getRevision());
-// Assert.assertNotSame("Unknown", VersionInfo.getDate());
-// Assert.assertNotSame("Unknown", VersionInfo.getUser());
-// Assert.assertNotSame("Unknown", VersionInfo.getUrl());
-// }
+ @Test
+ public void testValues() throws Exception {
+ Assert.assertNotSame("Unknown", VersionInfo.getVersion());
+ Assert.assertNotSame("Unknown", VersionInfo.getRevision());
+ Assert.assertNotSame("Unknown", VersionInfo.getDate());
+ Assert.assertNotSame("Unknown", VersionInfo.getUser());
+ Assert.assertNotSame("Unknown", VersionInfo.getUrl());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java b/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
index 205694a..19f81a8 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
@@ -34,105 +34,105 @@ import static org.apache.sqoop.json.TestUtil.*;
*
*/
public class TestConnectionBean {
-// @Test
-// public void testSerialization() {
-// Date created = new Date();
-// Date updated = new Date();
-// MConnection connection = getConnection("ahoj");
-// connection.setName("Connection");
-// connection.setPersistenceId(666);
-// connection.setCreationUser("admin");
-// connection.setCreationDate(created);
-// connection.setLastUpdateUser("user");
-// connection.setLastUpdateDate(updated);
-// connection.setEnabled(false);
-//
-// // Fill some data at the beginning
-// MStringInput input = (MStringInput) connection.getConnectorPart().getForms()
-// .get(0).getInputs().get(0);
-// input.setValue("Hi there!");
-//
-// // Serialize it to JSON object
-// ConnectionBean bean = new ConnectionBean(connection);
-// JSONObject json = bean.extract(false);
-//
-// // Check for sensitivity
-// JSONArray all = (JSONArray)json.get("all");
-// JSONObject allItem = (JSONObject)all.get(0);
-// JSONArray connectors = (JSONArray)allItem.get("connector");
-// JSONObject connector = (JSONObject)connectors.get(0);
-// JSONArray inputs = (JSONArray)connector.get("inputs");
-// for (Object input1 : inputs) {
-// assertTrue(((JSONObject)input1).containsKey("sensitive"));
-// }
-//
-// // "Move" it across network in text form
-// String string = json.toJSONString();
-//
-// // Retrieved transferred object
-// JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
-// ConnectionBean retrievedBean = new ConnectionBean();
-// retrievedBean.restore(retrievedJson);
-// MConnection target = retrievedBean.getConnections().get(0);
-//
-// // Check id and name
-// assertEquals(666, target.getPersistenceId());
-// assertEquals("Connection", target.getName());
-// assertEquals("admin", target.getCreationUser());
-// assertEquals(created, target.getCreationDate());
-// assertEquals("user", target.getLastUpdateUser());
-// assertEquals(updated, target.getLastUpdateDate());
-// assertEquals(false, target.getEnabled());
-//
-// // Test that value was correctly moved
-// MStringInput targetInput = (MStringInput) target.getConnectorPart()
-// .getForms().get(0).getInputs().get(0);
-// assertEquals("Hi there!", targetInput.getValue());
-// }
-//
-// @Test
-// public void testSensitivityFilter() {
-// Date created = new Date();
-// Date updated = new Date();
-// MConnection connection = getConnection("ahoj");
-// connection.setName("Connection");
-// connection.setPersistenceId(666);
-// connection.setCreationUser("admin");
-// connection.setCreationDate(created);
-// connection.setLastUpdateUser("user");
-// connection.setLastUpdateDate(updated);
-// connection.setEnabled(true);
-//
-// // Fill some data at the beginning
-// MStringInput input = (MStringInput) connection.getConnectorPart().getForms()
-// .get(0).getInputs().get(0);
-// input.setValue("Hi there!");
-//
-// // Serialize it to JSON object
-// ConnectionBean bean = new ConnectionBean(connection);
-// JSONObject json = bean.extract(false);
-// JSONObject jsonFiltered = bean.extract(true);
-//
-// // Sensitive values should exist
-// JSONArray all = (JSONArray)json.get("all");
-// JSONObject allItem = (JSONObject)all.get(0);
-// JSONArray connectors = (JSONArray)allItem.get("connector");
-// JSONObject connector = (JSONObject)connectors.get(0);
-// JSONArray inputs = (JSONArray)connector.get("inputs");
-// assertEquals(3, inputs.size());
-// // Inputs are ordered when creating connection
-// JSONObject password = (JSONObject)inputs.get(2);
-// assertTrue(password.containsKey("value"));
-//
-// // Sensitive values should not exist
-// all = (JSONArray)jsonFiltered.get("all");
-// allItem = (JSONObject)all.get(0);
-// connectors = (JSONArray)allItem.get("connector");
-// connector = (JSONObject)connectors.get(0);
-// inputs = (JSONArray)connector.get("inputs");
-// assertEquals(3, inputs.size());
-// // Inputs are ordered when creating connection
-// password = (JSONObject)inputs.get(2);
-// assertFalse(password.containsKey("value"));
-// }
+ @Test
+ public void testSerialization() {
+ Date created = new Date();
+ Date updated = new Date();
+ MConnection connection = getConnection("ahoj");
+ connection.setName("Connection");
+ connection.setPersistenceId(666);
+ connection.setCreationUser("admin");
+ connection.setCreationDate(created);
+ connection.setLastUpdateUser("user");
+ connection.setLastUpdateDate(updated);
+ connection.setEnabled(false);
+
+ // Fill some data at the beginning
+ MStringInput input = (MStringInput) connection.getConnectorPart().getForms()
+ .get(0).getInputs().get(0);
+ input.setValue("Hi there!");
+
+ // Serialize it to JSON object
+ ConnectionBean bean = new ConnectionBean(connection);
+ JSONObject json = bean.extract(false);
+
+ // Check for sensitivity
+ JSONArray all = (JSONArray)json.get("all");
+ JSONObject allItem = (JSONObject)all.get(0);
+ JSONArray connectors = (JSONArray)allItem.get("connector");
+ JSONObject connector = (JSONObject)connectors.get(0);
+ JSONArray inputs = (JSONArray)connector.get("inputs");
+ for (Object input1 : inputs) {
+ assertTrue(((JSONObject)input1).containsKey("sensitive"));
+ }
+
+ // "Move" it across network in text form
+ String string = json.toJSONString();
+
+ // Retrieved transferred object
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+ ConnectionBean retrievedBean = new ConnectionBean();
+ retrievedBean.restore(retrievedJson);
+ MConnection target = retrievedBean.getConnections().get(0);
+
+ // Check id and name
+ assertEquals(666, target.getPersistenceId());
+ assertEquals("Connection", target.getName());
+ assertEquals("admin", target.getCreationUser());
+ assertEquals(created, target.getCreationDate());
+ assertEquals("user", target.getLastUpdateUser());
+ assertEquals(updated, target.getLastUpdateDate());
+ assertEquals(false, target.getEnabled());
+
+ // Test that value was correctly moved
+ MStringInput targetInput = (MStringInput) target.getConnectorPart()
+ .getForms().get(0).getInputs().get(0);
+ assertEquals("Hi there!", targetInput.getValue());
+ }
+
+ @Test
+ public void testSensitivityFilter() {
+ Date created = new Date();
+ Date updated = new Date();
+ MConnection connection = getConnection("ahoj");
+ connection.setName("Connection");
+ connection.setPersistenceId(666);
+ connection.setCreationUser("admin");
+ connection.setCreationDate(created);
+ connection.setLastUpdateUser("user");
+ connection.setLastUpdateDate(updated);
+ connection.setEnabled(true);
+
+ // Fill some data at the beginning
+ MStringInput input = (MStringInput) connection.getConnectorPart().getForms()
+ .get(0).getInputs().get(0);
+ input.setValue("Hi there!");
+
+ // Serialize it to JSON object
+ ConnectionBean bean = new ConnectionBean(connection);
+ JSONObject json = bean.extract(false);
+ JSONObject jsonFiltered = bean.extract(true);
+
+ // Sensitive values should exist
+ JSONArray all = (JSONArray)json.get("all");
+ JSONObject allItem = (JSONObject)all.get(0);
+ JSONArray connectors = (JSONArray)allItem.get("connector");
+ JSONObject connector = (JSONObject)connectors.get(0);
+ JSONArray inputs = (JSONArray)connector.get("inputs");
+ assertEquals(3, inputs.size());
+ // Inputs are ordered when creating connection
+ JSONObject password = (JSONObject)inputs.get(2);
+ assertTrue(password.containsKey("value"));
+
+ // Sensitive values should not exist
+ all = (JSONArray)jsonFiltered.get("all");
+ allItem = (JSONObject)all.get(0);
+ connectors = (JSONArray)allItem.get("connector");
+ connector = (JSONObject)connectors.get(0);
+ inputs = (JSONArray)connector.get("inputs");
+ assertEquals(3, inputs.size());
+ // Inputs are ordered when creating connection
+ password = (JSONObject)inputs.get(2);
+ assertFalse(password.containsKey("value"));
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java b/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
index 58ea308..e078474 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
@@ -37,40 +37,40 @@ import static org.apache.sqoop.json.TestUtil.*;
*/
public class TestConnectorBean {
-// /**
-// * Test that by JSON serialization followed by deserialization we will get
-// * equal connector object.
-// */
-// @Test
-// public void testSerialization() {
-// // Create testing connector
-// List<MConnector> connectors = new LinkedList<MConnector>();
-// connectors.add(getConnector("jdbc"));
-// connectors.add(getConnector("mysql"));
-//
-// // Create testing bundles
-// Map<Long, ResourceBundle> bundles = new HashMap<Long, ResourceBundle>();
-// bundles.put(1L, getResourceBundle());
-// bundles.put(2L, getResourceBundle());
-//
-// // Serialize it to JSON object
-// ConnectorBean bean = new ConnectorBean(connectors, bundles);
-// JSONObject json = bean.extract(false);
-//
-// // "Move" it across network in text form
-// String string = json.toJSONString();
-//
-// // Retrieved transferred object
-// JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
-// ConnectorBean retrievedBean = new ConnectorBean();
-// retrievedBean.restore(retrievedJson);
-//
-// assertEquals(connectors.size(), retrievedBean.getConnectors().size());
-// assertEquals(connectors.get(0), retrievedBean.getConnectors().get(0));
-//
-// ResourceBundle retrievedBundle = retrievedBean.getResourceBundles().get(1L);
-// assertNotNull(retrievedBundle);
-// assertEquals("a", retrievedBundle.getString("a"));
-// assertEquals("b", retrievedBundle.getString("b"));
-// }
+ /**
+ * Test that by JSON serialization followed by deserialization we will get
+ * equal connector object.
+ */
+ @Test
+ public void testSerialization() {
+ // Create testing connector
+ List<MConnector> connectors = new LinkedList<MConnector>();
+ connectors.add(getConnector("jdbc"));
+ connectors.add(getConnector("mysql"));
+
+ // Create testing bundles
+ Map<Long, ResourceBundle> bundles = new HashMap<Long, ResourceBundle>();
+ bundles.put(1L, getResourceBundle());
+ bundles.put(2L, getResourceBundle());
+
+ // Serialize it to JSON object
+ ConnectorBean bean = new ConnectorBean(connectors, bundles);
+ JSONObject json = bean.extract(false);
+
+ // "Move" it across network in text form
+ String string = json.toJSONString();
+
+ // Retrieved transferred object
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+ ConnectorBean retrievedBean = new ConnectorBean();
+ retrievedBean.restore(retrievedJson);
+
+ assertEquals(connectors.size(), retrievedBean.getConnectors().size());
+ assertEquals(connectors.get(0), retrievedBean.getConnectors().get(0));
+
+ ResourceBundle retrievedBundle = retrievedBean.getResourceBundles().get(1L);
+ assertNotNull(retrievedBundle);
+ assertEquals("a", retrievedBundle.getString("a"));
+ assertEquals("b", retrievedBundle.getString("b"));
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/json/TestFrameworkBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestFrameworkBean.java b/common/src/test/java/org/apache/sqoop/json/TestFrameworkBean.java
index e667755..5cc110a 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestFrameworkBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestFrameworkBean.java
@@ -34,31 +34,31 @@ import static org.junit.Assert.*;
*/
public class TestFrameworkBean {
-// /**
-// * Test that by JSON serialization followed by deserialization we will get
-// * equal framework object.
-// */
-// @Test
-// public void testSerialization() {
-// MFramework framework = getFramework();
-//
-// // Serialize it to JSON object
-// FrameworkBean bean = new FrameworkBean(framework, getResourceBundle());
-// JSONObject json = bean.extract(false);
-//
-// // "Move" it across network in text form
-// String string = json.toJSONString();
-//
-// // Retrieved transferred object
-// JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
-// FrameworkBean retrievedBean = new FrameworkBean();
-// retrievedBean.restore(retrievedJson);
-//
-// assertEquals(framework, retrievedBean.getFramework());
-//
-// ResourceBundle retrievedBundle = retrievedBean.getResourceBundle();
-// assertEquals("a", retrievedBundle.getString("a"));
-// assertEquals("b", retrievedBundle.getString("b"));
-// }
+ /**
+ * Test that by JSON serialization followed by deserialization we will get
+ * equal framework object.
+ */
+ @Test
+ public void testSerialization() {
+ MFramework framework = getFramework();
+
+ // Serialize it to JSON object
+ FrameworkBean bean = new FrameworkBean(framework, getResourceBundle());
+ JSONObject json = bean.extract(false);
+
+ // "Move" it across network in text form
+ String string = json.toJSONString();
+
+ // Retrieved transferred object
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+ FrameworkBean retrievedBean = new FrameworkBean();
+ retrievedBean.restore(retrievedJson);
+
+ assertEquals(framework, retrievedBean.getFramework());
+
+ ResourceBundle retrievedBundle = retrievedBean.getResourceBundle();
+ assertEquals("a", retrievedBundle.getString("a"));
+ assertEquals("b", retrievedBundle.getString("b"));
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
index 8638408..3106d39 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
@@ -17,62 +17,72 @@
*/
package org.apache.sqoop.json;
-//import org.apache.sqoop.model.MJob;
-//import org.apache.sqoop.model.MStringInput;
-//import org.json.simple.JSONObject;
-//import org.json.simple.JSONValue;
-//import org.json.simple.parser.ParseException;
-//import org.junit.Test;
-//
-//import java.util.Date;
-//
-//import static junit.framework.Assert.assertEquals;
-//import static org.apache.sqoop.json.TestUtil.getJob;
+import org.apache.sqoop.common.Direction;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MStringInput;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+import org.json.simple.parser.ParseException;
+import org.junit.Test;
+
+import java.util.Date;
+
+import static junit.framework.Assert.assertEquals;
+import static org.apache.sqoop.json.TestUtil.getJob;
/**
*
*/
public class TestJobBean {
-// @Test
-// public void testSerialization() throws ParseException {
-// Date created = new Date();
-// Date updated = new Date();
-// MJob job = getJob("ahoj", MJob.Type.IMPORT);
-// job.setName("The big job");
-// job.setPersistenceId(666);
-// job.setCreationDate(created);
-// job.setLastUpdateDate(updated);
-// job.setEnabled(false);
-//
-// // Fill some data at the beginning
-// MStringInput input = (MStringInput) job.getFromPart().getForms()
-// .get(0).getInputs().get(0);
-// input.setValue("Hi there!");
-//
-// // Serialize it to JSON object
-// JobBean bean = new JobBean(job);
-// JSONObject json = bean.extract(false);
-//
-// // "Move" it across network in text form
-// String string = json.toJSONString();
-//
-// // Retrieved transferred object
-// JSONObject retrievedJson = (JSONObject)JSONValue.parseWithException(string);
-// JobBean retrievedBean = new JobBean();
-// retrievedBean.restore(retrievedJson);
-// MJob target = retrievedBean.getJobs().get(0);
-//
-// // Check id and name
-// assertEquals(666, target.getPersistenceId());
-// assertEquals(MJob.Type.IMPORT, target.getType());
-// assertEquals("The big job", target.getName());
-// assertEquals(created, target.getCreationDate());
-// assertEquals(updated, target.getLastUpdateDate());
-// assertEquals(false, target.getEnabled());
-//
-// // Test that value was correctly moved
-// MStringInput targetInput = (MStringInput) target.getFromPart()
-// .getForms().get(0).getInputs().get(0);
-// assertEquals("Hi there!", targetInput.getValue());
-// }
+ @Test
+ public void testSerialization() throws ParseException {
+ Date created = new Date();
+ Date updated = new Date();
+ MJob job = getJob("ahoj");
+ job.setName("The big job");
+ job.setPersistenceId(666);
+ job.setCreationDate(created);
+ job.setLastUpdateDate(updated);
+ job.setEnabled(false);
+
+ // Fill some data at the beginning
+ MStringInput input = (MStringInput) job.getConnectorPart(Direction.FROM)
+ .getForms().get(0).getInputs().get(0);
+ input.setValue("Hi there!");
+ input = (MStringInput) job.getConnectorPart(Direction.TO)
+ .getForms().get(0).getInputs().get(0);
+ input.setValue("Hi there again!");
+
+ // Serialize it to JSON object
+ JobBean bean = new JobBean(job);
+ JSONObject json = bean.extract(false);
+
+ // "Move" it across network in text form
+ String string = json.toJSONString();
+
+ // Retrieved transferred object
+ JSONObject retrievedJson = (JSONObject)JSONValue.parseWithException(string);
+ JobBean retrievedBean = new JobBean();
+ retrievedBean.restore(retrievedJson);
+ MJob target = retrievedBean.getJobs().get(0);
+
+ // Check id and name
+ assertEquals(666, target.getPersistenceId());
+ assertEquals(target.getConnectionId(Direction.FROM), 1);
+ assertEquals(target.getConnectionId(Direction.TO), 2);
+ assertEquals(target.getConnectorId(Direction.FROM), 1);
+ assertEquals(target.getConnectorId(Direction.TO), 2);
+ assertEquals("The big job", target.getName());
+ assertEquals(created, target.getCreationDate());
+ assertEquals(updated, target.getLastUpdateDate());
+ assertEquals(false, target.getEnabled());
+
+ // Test that value was correctly moved
+ MStringInput targetInput = (MStringInput) target.getConnectorPart(Direction.FROM)
+ .getForms().get(0).getInputs().get(0);
+ assertEquals("Hi there!", targetInput.getValue());
+ targetInput = (MStringInput) target.getConnectorPart(Direction.TO)
+ .getForms().get(0).getInputs().get(0);
+ assertEquals("Hi there again!", targetInput.getValue());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java b/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java
index ce107a8..5daab76 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestSchemaBean.java
@@ -29,24 +29,24 @@ import org.json.simple.JSONValue;
* as a means of transfer.
*/
public class TestSchemaBean extends TestSchemaSerialization {
-//
-// /**
-// * Override the transfer method to use the SchemaBean.
-// *
-// * @param schema
-// * @return
-// */
-// @Override
-// protected Schema transfer(Schema schema) {
-// SchemaBean extractBean = new SchemaBean(schema);
-// JSONObject extractJson = extractBean.extract(true);
-//
-// String transferredString = extractJson.toJSONString();
-//
-// JSONObject restoreJson = (JSONObject) JSONValue.parse(transferredString);
-// SchemaBean restoreBean = new SchemaBean();
-// restoreBean.restore(restoreJson);
-//
-// return restoreBean.getSchema();
-// }
+
+ /**
+ * Override the transfer method to use the SchemaBean.
+ *
+ * @param schema
+ * @return
+ */
+ @Override
+ protected Schema transfer(Schema schema) {
+ SchemaBean extractBean = new SchemaBean(schema);
+ JSONObject extractJson = extractBean.extract(true);
+
+ String transferredString = extractJson.toJSONString();
+
+ JSONObject restoreJson = (JSONObject) JSONValue.parse(transferredString);
+ SchemaBean restoreBean = new SchemaBean();
+ restoreBean.restore(restoreJson);
+
+ return restoreBean.getSchema();
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/json/TestUtil.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestUtil.java b/common/src/test/java/org/apache/sqoop/json/TestUtil.java
index d3e118b..a9aa233 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestUtil.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestUtil.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.json;
+import org.apache.sqoop.common.Direction;
import org.apache.sqoop.model.MConnection;
import org.apache.sqoop.model.MConnectionForms;
import org.apache.sqoop.model.MConnector;
@@ -38,115 +39,108 @@ import java.util.ResourceBundle;
*
*/
public class TestUtil {
-// public static MConnector getConnector(String name) {
-// return new MConnector(name, name + ".class", "1.0-test",
-// getConnectionForms(), getAllJobForms());
-// }
-//
-// public static MFramework getFramework() {
-// return new MFramework(getConnectionForms(), getAllJobForms(), "1");
-// }
-//
-// public static MConnection getConnection(String name) {
-// return new MConnection(1,
-// getConnector(name).getConnectionForms(),
-// getFramework().getConnectionForms()
-// );
-// }
-//
-// public static MJob getJob(String name, MJob.Type type) {
-// return new MJob(1, 1,
-// type,
-// getConnector(name).getJobForms(type),
-// getFramework().getJobForms(type)
-// );
-// }
-//
-// public static MConnectionForms getConnectionForms() {
-// List<MInput<?>> inputs;
-// MStringInput input;
-// MForm form;
-// List<MForm> connectionForms = new ArrayList<MForm>();
-// inputs = new ArrayList<MInput<?>>();
-//
-// input = new MStringInput("url", false, (short) 10);
-// input.setPersistenceId(1);
-// inputs.add(input);
-//
-// input = new MStringInput("username", false, (short) 10);
-// input.setPersistenceId(2);
-// input.setValue("test");
-// inputs.add(input);
-//
-// input = new MStringInput("password", true, (short) 10);
-// input.setPersistenceId(3);
-// input.setValue("test");
-// inputs.add(input);
-//
-// form = new MForm("connection", inputs);
-// form.setPersistenceId(10);
-// connectionForms.add(form);
-//
-// return new MConnectionForms(connectionForms);
-// }
-//
-// public static MJobForms getJobForms(MJob.Type type) {
-// List<MInput<?>> inputs;
-// MStringInput input;
-// MForm form;
-// List<MForm> jobForms = new ArrayList<MForm>();
-//
-// inputs = new ArrayList<MInput<?>>();
-//
-// input = new MStringInput("A", false, (short) 10);
-// input.setPersistenceId(4);
-// inputs.add(input);
-//
-// input = new MStringInput("B", false, (short) 10);
-// input.setPersistenceId(5);
-// inputs.add(input);
-//
-// input = new MStringInput("C", false, (short) 10);
-// input.setPersistenceId(6);
-// inputs.add(input);
-//
-// form = new MForm("Z", inputs);
-// form.setPersistenceId(11);
-// jobForms.add(form);
-//
-// inputs = new ArrayList<MInput<?>>();
-//
-// input = new MStringInput("D", false, (short) 10);
-// input.setPersistenceId(7);
-// inputs.add(input);
-//
-// input = new MStringInput("E", false, (short) 10);
-// input.setPersistenceId(8);
-// inputs.add(input);
-//
-// input = new MStringInput("F", false, (short) 10);
-// input.setPersistenceId(9);
-// inputs.add(input);
-//
-// form = new MForm("connection", inputs);
-// form.setPersistenceId(12);
-// jobForms.add(form);
-//
-// return new MJobForms(type, jobForms);
-// }
-//
-// public static List<MJobForms> getAllJobForms() {
-// List<MJobForms> jobs = new ArrayList<MJobForms>();
-// jobs.add(getJobForms(MJob.Type.IMPORT));
-//
-// return jobs;
-// }
-//
-// public static ResourceBundle getResourceBundle() {
-// Map<String, Object> map = new HashMap<String, Object>();
-// map.put("a", "a");
-// map.put("b", "b");
-//
-// return new MapResourceBundle(map);
-// }
+ public static MConnector getConnector(String name) {
+ return new MConnector(name, name + ".class", "1.0-test",
+ getConnectionForms(), getJobForms(), getJobForms());
+ }
+
+ public static MFramework getFramework() {
+ return new MFramework(getConnectionForms(), getJobForms(), "1");
+ }
+
+ public static MConnection getConnection(String name) {
+ return new MConnection(1,
+ getConnector(name).getConnectionForms(),
+ getFramework().getConnectionForms()
+ );
+ }
+
+ public static MJob getJob(String name) {
+ return new MJob(1, 2, 1, 2,
+ getConnector(name).getJobForms(Direction.FROM),
+ getConnector(name).getJobForms(Direction.TO),
+ getFramework().getJobForms()
+ );
+ }
+
+ public static MConnectionForms getConnectionForms() {
+ List<MInput<?>> inputs;
+ MStringInput input;
+ MForm form;
+ List<MForm> connectionForms = new ArrayList<MForm>();
+ inputs = new ArrayList<MInput<?>>();
+
+ input = new MStringInput("url", false, (short) 10);
+ input.setPersistenceId(1);
+ inputs.add(input);
+
+ input = new MStringInput("username", false, (short) 10);
+ input.setPersistenceId(2);
+ input.setValue("test");
+ inputs.add(input);
+
+ input = new MStringInput("password", true, (short) 10);
+ input.setPersistenceId(3);
+ input.setValue("test");
+ inputs.add(input);
+
+ form = new MForm("connection", inputs);
+ form.setPersistenceId(10);
+ connectionForms.add(form);
+
+ return new MConnectionForms(connectionForms);
+ }
+
+ public static MJobForms getJobForms() {
+ List<MInput<?>> inputs;
+ MStringInput input;
+ MForm form;
+ List<MForm> jobForms = new ArrayList<MForm>();
+
+ inputs = new ArrayList<MInput<?>>();
+
+ input = new MStringInput("A", false, (short) 10);
+ input.setPersistenceId(4);
+ inputs.add(input);
+
+ input = new MStringInput("B", false, (short) 10);
+ input.setPersistenceId(5);
+ inputs.add(input);
+
+ input = new MStringInput("C", false, (short) 10);
+ input.setPersistenceId(6);
+ inputs.add(input);
+
+ form = new MForm("Z", inputs);
+ form.setPersistenceId(11);
+ jobForms.add(form);
+
+ inputs = new ArrayList<MInput<?>>();
+
+ input = new MStringInput("D", false, (short) 10);
+ input.setPersistenceId(7);
+ inputs.add(input);
+
+ input = new MStringInput("E", false, (short) 10);
+ input.setPersistenceId(8);
+ inputs.add(input);
+
+ input = new MStringInput("F", false, (short) 10);
+ input.setPersistenceId(9);
+ inputs.add(input);
+
+ form = new MForm("connection", inputs);
+ form.setPersistenceId(12);
+ jobForms.add(form);
+
+ return new MJobForms(jobForms);
+ }
+
+ public static ResourceBundle getResourceBundle() {
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("a", "a");
+ map.put("b", "b");
+
+ return new MapResourceBundle(map);
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java b/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
index 704d55b..c6086dd 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.json;
+import org.apache.sqoop.common.Direction;
import org.apache.sqoop.validation.Status;
import org.apache.sqoop.validation.Validation;
import org.json.simple.JSONObject;
@@ -32,76 +33,143 @@ import static org.junit.Assert.*;
*
*/
public class TestValidationBean {
-//
-// @Test
-// public void testSerialization() {
-// // Serialize it to JSON object
-// ValidationBean bean = new ValidationBean(
-// getValidation(Status.FINE),
-// getValidation(Status.UNACCEPTABLE)
-// );
-// JSONObject json = bean.extract(false);
-//
-// // "Move" it across network in text form
-// String string = json.toJSONString();
-//
-// // Retrieved transferred object
-// JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
-// ValidationBean retrievedBean = new ValidationBean();
-// retrievedBean.restore(retrievedJson);
-//
-// assertNull(retrievedBean.getId());
-//
-// Validation.FormInput fa = new Validation.FormInput("f", "i");
-// Validation.FormInput fb = new Validation.FormInput("f2", "i2");
-//
-// Validation connector = retrievedBean.getConnectorValidation();
-// assertEquals(Status.FINE, connector.getStatus());
-// assertEquals(2, connector.getMessages().size());
-// assertTrue(connector.getMessages().containsKey(fa));
-// assertEquals(new Validation.Message(Status.FINE, "d"),
-// connector.getMessages().get(fa));
-//
-// Validation framework = retrievedBean.getFrameworkValidation();
-// assertEquals(Status.UNACCEPTABLE, framework.getStatus());
-// assertEquals(2, framework.getMessages().size());
-// assertTrue(framework.getMessages().containsKey(fb));
-// assertEquals(new Validation.Message(Status.UNACCEPTABLE, "c"),
-// framework.getMessages().get(fb));
-// }
-//
-// @Test
-// public void testId() {
-// // Serialize it to JSON object
-// ValidationBean bean = new ValidationBean(
-// getValidation(Status.FINE),
-// getValidation(Status.FINE)
-// );
-// bean.setId((long) 10);
-// JSONObject json = bean.extract(false);
-//
-// // "Move" it across network in text form
-// String string = json.toJSONString();
-//
-// // Retrieved transferred object
-// JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
-// ValidationBean retrievedBean = new ValidationBean();
-// retrievedBean.restore(retrievedJson);
-//
-// assertEquals((Long)(long) 10, retrievedBean.getId());
-// }
-//
-// public Validation getValidation(Status status) {
-// Map<Validation.FormInput, Validation.Message> messages =
-// new HashMap<Validation.FormInput, Validation.Message>();
-//
-// messages.put(
-// new Validation.FormInput("f", "i"),
-// new Validation.Message(status, "d"));
-// messages.put(
-// new Validation.FormInput("f2", "i2"),
-// new Validation.Message(status, "c"));
-//
-// return new Validation(status, messages);
-// }
+
+ @Test
+ public void testJobValidationBeanSerialization() {
+ // Serialize it to JSON object
+ JobValidationBean bean = new JobValidationBean(
+ getValidation(Status.FINE),
+ getValidation(Status.UNACCEPTABLE),
+ getValidation(Status.FINE)
+ );
+ JSONObject json = bean.extract(false);
+
+ // "Move" it across network in text form
+ String string = json.toJSONString();
+
+ // Retrieved transferred object
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+ JobValidationBean retrievedBean = new JobValidationBean();
+ retrievedBean.restore(retrievedJson);
+
+ assertNull(retrievedBean.getId());
+
+ Validation.FormInput fa = new Validation.FormInput("f", "i");
+ Validation.FormInput fb = new Validation.FormInput("f2", "i2");
+
+ Validation fromConnector = retrievedBean.getConnectorValidation(Direction.FROM);
+ assertEquals(Status.FINE, fromConnector.getStatus());
+ assertEquals(2, fromConnector.getMessages().size());
+ assertTrue(fromConnector.getMessages().containsKey(fa));
+ assertEquals(new Validation.Message(Status.FINE, "d"),
+ fromConnector.getMessages().get(fa));
+
+ Validation toConnector = retrievedBean.getConnectorValidation(Direction.TO);
+ assertEquals(Status.FINE, toConnector.getStatus());
+ assertEquals(2, toConnector.getMessages().size());
+ assertTrue(toConnector.getMessages().containsKey(fa));
+ assertEquals(new Validation.Message(Status.FINE, "d"),
+ toConnector.getMessages().get(fa));
+
+ Validation framework = retrievedBean.getFrameworkValidation();
+ assertEquals(Status.UNACCEPTABLE, framework.getStatus());
+ assertEquals(2, framework.getMessages().size());
+ assertTrue(framework.getMessages().containsKey(fb));
+ assertEquals(new Validation.Message(Status.UNACCEPTABLE, "c"),
+ framework.getMessages().get(fb));
+ }
+
+ @Test
+ public void testJobValidationBeanId() {
+ // Serialize it to JSON object
+ JobValidationBean bean = new JobValidationBean(
+ getValidation(Status.FINE),
+ getValidation(Status.FINE),
+ getValidation(Status.FINE)
+ );
+ bean.setId((long) 10);
+ JSONObject json = bean.extract(false);
+
+ // "Move" it across network in text form
+ String string = json.toJSONString();
+
+ // Retrieved transferred object
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+ JobValidationBean retrievedBean = new JobValidationBean();
+ retrievedBean.restore(retrievedJson);
+
+ assertEquals((Long)(long) 10, retrievedBean.getId());
+ }
+
+ @Test
+ public void testConnectionValidationBeanSerialization() {
+ // Serialize it to JSON object
+ ConnectionValidationBean bean = new ConnectionValidationBean(
+ getValidation(Status.FINE),
+ getValidation(Status.UNACCEPTABLE)
+ );
+ JSONObject json = bean.extract(false);
+
+ // "Move" it across network in text form
+ String string = json.toJSONString();
+
+ // Retrieved transferred object
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+ ConnectionValidationBean retrievedBean = new ConnectionValidationBean();
+ retrievedBean.restore(retrievedJson);
+
+ assertNull(retrievedBean.getId());
+
+ Validation.FormInput fa = new Validation.FormInput("f", "i");
+ Validation.FormInput fb = new Validation.FormInput("f2", "i2");
+
+ Validation connector = retrievedBean.getConnectorValidation();
+ assertEquals(Status.FINE, connector.getStatus());
+ assertEquals(2, connector.getMessages().size());
+ assertTrue(connector.getMessages().containsKey(fa));
+ assertEquals(new Validation.Message(Status.FINE, "d"),
+ connector.getMessages().get(fa));
+
+ Validation framework = retrievedBean.getFrameworkValidation();
+ assertEquals(Status.UNACCEPTABLE, framework.getStatus());
+ assertEquals(2, framework.getMessages().size());
+ assertTrue(framework.getMessages().containsKey(fb));
+ assertEquals(new Validation.Message(Status.UNACCEPTABLE, "c"),
+ framework.getMessages().get(fb));
+ }
+
+ @Test
+ public void testConnectionValidationBeanId() {
+ // Serialize it to JSON object
+ ConnectionValidationBean bean = new ConnectionValidationBean(
+ getValidation(Status.FINE),
+ getValidation(Status.FINE)
+ );
+ bean.setId((long) 10);
+ JSONObject json = bean.extract(false);
+
+ // "Move" it across network in text form
+ String string = json.toJSONString();
+
+ // Retrieved transferred object
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+ ConnectionValidationBean retrievedBean = new ConnectionValidationBean();
+ retrievedBean.restore(retrievedJson);
+
+ assertEquals((Long)(long) 10, retrievedBean.getId());
+ }
+
+ public Validation getValidation(Status status) {
+ Map<Validation.FormInput, Validation.Message> messages =
+ new HashMap<Validation.FormInput, Validation.Message>();
+
+ messages.put(
+ new Validation.FormInput("f", "i"),
+ new Validation.Message(status, "d"));
+ messages.put(
+ new Validation.FormInput("f2", "i2"),
+ new Validation.Message(status, "c"));
+
+ return new Validation(status, messages);
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/json/util/TestFormSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestFormSerialization.java b/common/src/test/java/org/apache/sqoop/json/util/TestFormSerialization.java
index 9cd7305..c4223ec 100644
--- a/common/src/test/java/org/apache/sqoop/json/util/TestFormSerialization.java
+++ b/common/src/test/java/org/apache/sqoop/json/util/TestFormSerialization.java
@@ -42,116 +42,116 @@ import static org.junit.Assert.assertNotNull;
*/
public class TestFormSerialization {
-// @Test
-// public void testAllDataTypes() {
-// // Inserted values
-// Map<String, String> map = new HashMap<String, String>();
-// map.put("A", "B");
-//
-// // Fill form with all values
-// MForm form = getForm();
-// form.getStringInput("String").setValue("A");
-// form.getMapInput("Map").setValue(map);
-// form.getIntegerInput("Integer").setValue(1);
-// form.getBooleanInput("Boolean").setValue(true);
-// form.getEnumInput("Enum").setValue("YES");
-//
-// // Serialize that into JSON
-// JSONObject jsonObject = FormSerialization.extractForm(form, false);
-// assertNotNull(jsonObject);
-//
-// // Exchange the data on string level
-// String serializedJson = jsonObject.toJSONString();
-// JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
-//
-// // And retrieve back from JSON representation
-// MForm retrieved = FormSerialization.restoreForm(retrievedJson);
-//
-// // Verify all expected values
-// assertEquals("A", retrieved.getStringInput("String").getValue());
-// assertEquals(map, retrieved.getMapInput("Map").getValue());
-// assertEquals(1, (int)retrieved.getIntegerInput("Integer").getValue());
-// assertEquals(true, retrieved.getBooleanInput("Boolean").getValue());
-// assertEquals("YES", retrieved.getEnumInput("Enum").getValue());
-// }
-//
-// @Test
-// public void testMapDataType() {
-// MForm form = getMapForm();
-//
-// // Inserted values
-// Map<String, String> map = new HashMap<String, String>();
-// map.put("A", "B");
-// form.getMapInput("Map").setValue(map);
-//
-// // Serialize
-// JSONObject jsonObject = FormSerialization.extractForm(form, false);
-// String serializedJson = jsonObject.toJSONString();
-//
-// // Deserialize
-// JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
-// MForm retrieved = FormSerialization.restoreForm(retrievedJson);
-// assertEquals(map, retrieved.getMapInput("Map").getValue());
-// }
-//
-// @Test(expected=SqoopException.class)
-// public void testMapDataTypeException() {
-// MForm form = getMapForm();
-//
-// // Inserted values
-// Map<String, String> map = new HashMap<String, String>();
-// map.put("A", "B");
-// form.getMapInput("Map").setValue(map);
-//
-// // Serialize
-// JSONObject jsonObject = FormSerialization.extractForm(form, false);
-// String serializedJson = jsonObject.toJSONString();
-//
-// // Replace map value with a fake string to force exception
-// String badSerializedJson = serializedJson.replace("{\"A\":\"B\"}", "\"nonsensical string\"");
-// System.out.println(badSerializedJson);
-// JSONObject retrievedJson = (JSONObject) JSONValue.parse(badSerializedJson);
-// FormSerialization.restoreForm(retrievedJson);
-// }
-//
-// protected MForm getMapForm() {
-// List<MInput<?>> inputs;
-// MInput input;
-//
-// inputs = new LinkedList<MInput<?>>();
-//
-// input = new MMapInput("Map", false);
-// inputs.add(input);
-//
-// return new MForm("f", inputs);
-// }
-//
-// /**
-// * Return form with all data types.
-// *
-// * @return
-// */
-// protected MForm getForm() {
-// List<MInput<?>> inputs;
-// MInput input;
-//
-// inputs = new LinkedList<MInput<?>>();
-//
-// input = new MStringInput("String", false, (short)30);
-// inputs.add(input);
-//
-// input = new MMapInput("Map", false);
-// inputs.add(input);
-//
-// input = new MIntegerInput("Integer", false);
-// inputs.add(input);
-//
-// input = new MBooleanInput("Boolean", false);
-// inputs.add(input);
-//
-// input = new MEnumInput("Enum", false, new String[] {"YES", "NO"});
-// inputs.add(input);
-//
-// return new MForm("f", inputs);
-// }
+ @Test
+ public void testAllDataTypes() {
+ // Inserted values
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("A", "B");
+
+ // Fill form with all values
+ MForm form = getForm();
+ form.getStringInput("String").setValue("A");
+ form.getMapInput("Map").setValue(map);
+ form.getIntegerInput("Integer").setValue(1);
+ form.getBooleanInput("Boolean").setValue(true);
+ form.getEnumInput("Enum").setValue("YES");
+
+ // Serialize that into JSON
+ JSONObject jsonObject = FormSerialization.extractForm(form, false);
+ assertNotNull(jsonObject);
+
+ // Exchange the data on string level
+ String serializedJson = jsonObject.toJSONString();
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
+
+ // And retrieve back from JSON representation
+ MForm retrieved = FormSerialization.restoreForm(retrievedJson);
+
+ // Verify all expected values
+ assertEquals("A", retrieved.getStringInput("String").getValue());
+ assertEquals(map, retrieved.getMapInput("Map").getValue());
+ assertEquals(1, (int)retrieved.getIntegerInput("Integer").getValue());
+ assertEquals(true, retrieved.getBooleanInput("Boolean").getValue());
+ assertEquals("YES", retrieved.getEnumInput("Enum").getValue());
+ }
+
+ @Test
+ public void testMapDataType() {
+ MForm form = getMapForm();
+
+ // Inserted values
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("A", "B");
+ form.getMapInput("Map").setValue(map);
+
+ // Serialize
+ JSONObject jsonObject = FormSerialization.extractForm(form, false);
+ String serializedJson = jsonObject.toJSONString();
+
+ // Deserialize
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
+ MForm retrieved = FormSerialization.restoreForm(retrievedJson);
+ assertEquals(map, retrieved.getMapInput("Map").getValue());
+ }
+
+ @Test(expected=SqoopException.class)
+ public void testMapDataTypeException() {
+ MForm form = getMapForm();
+
+ // Inserted values
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("A", "B");
+ form.getMapInput("Map").setValue(map);
+
+ // Serialize
+ JSONObject jsonObject = FormSerialization.extractForm(form, false);
+ String serializedJson = jsonObject.toJSONString();
+
+ // Replace map value with a fake string to force exception
+ String badSerializedJson = serializedJson.replace("{\"A\":\"B\"}", "\"nonsensical string\"");
+ System.out.println(badSerializedJson);
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(badSerializedJson);
+ FormSerialization.restoreForm(retrievedJson);
+ }
+
+ protected MForm getMapForm() {
+ List<MInput<?>> inputs;
+ MInput input;
+
+ inputs = new LinkedList<MInput<?>>();
+
+ input = new MMapInput("Map", false);
+ inputs.add(input);
+
+ return new MForm("f", inputs);
+ }
+
+ /**
+ * Return form with all data types.
+ *
+ * @return
+ */
+ protected MForm getForm() {
+ List<MInput<?>> inputs;
+ MInput input;
+
+ inputs = new LinkedList<MInput<?>>();
+
+ input = new MStringInput("String", false, (short)30);
+ inputs.add(input);
+
+ input = new MMapInput("Map", false);
+ inputs.add(input);
+
+ input = new MIntegerInput("Integer", false);
+ inputs.add(input);
+
+ input = new MBooleanInput("Boolean", false);
+ inputs.add(input);
+
+ input = new MEnumInput("Enum", false, new String[] {"YES", "NO"});
+ inputs.add(input);
+
+ return new MForm("f", inputs);
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java b/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
index e36308d..ab5bbd4 100644
--- a/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
+++ b/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
@@ -43,135 +43,135 @@ import static org.junit.Assert.assertEquals;
*/
public class TestSchemaSerialization {
-// @Test
-// public void testArray() {
-// Schema array = new Schema("array").addColumn(new Array("a", new Decimal()));
-// transferAndAssert(array);
-// }
-//
-// @Test
-// public void testBinary() {
-// Schema binary = new Schema("b").addColumn(new Binary("A", 100L));
-// transferAndAssert(binary);
-// }
-//
-// @Test
-// public void testBit() {
-// Schema bit = new Schema("b").addColumn(new Bit("B"));
-// transferAndAssert(bit);
-// }
-//
-// @Test
-// public void testDate() {
-// Schema date = new Schema("d").addColumn(new Date("d"));
-// transferAndAssert(date);
-// }
-//
-// @Test
-// public void testDateTime() {
-// Schema dateTime = new Schema("dt").addColumn(new DateTime("dt", Boolean.FALSE, Boolean.TRUE));
-// transferAndAssert(dateTime);
-// }
-//
-// @Test
-// public void testDecimal() {
-// Schema decimal = new Schema("d").addColumn(new Decimal("d", 12L, 15L));
-// transferAndAssert(decimal);
-// }
-//
-// @Test
-// public void testEnum() {
-// Schema e = new Schema("e").addColumn(new Enum("e", new Text()));
-// transferAndAssert(e);
-// }
-//
-// @Test
-// public void testFixedPoint() {
-// Schema f = new Schema("f").addColumn(new FixedPoint("fp", 4L, Boolean.FALSE));
-// transferAndAssert(f);
-// }
-//
-// @Test
-// public void testFloatingPoint() {
-// Schema fp = new Schema("fp").addColumn(new FloatingPoint("k", 4L));
-// transferAndAssert(fp);
-// }
-//
-// @Test
-// public void testMap() {
-// Schema m = new Schema("m").addColumn(new Map("m", new Text(), new Decimal()));
-// transferAndAssert(m);
-// }
-//
-// @Test
-// public void testSet() {
-// Schema s = new Schema("s").addColumn(new Set("b", new Binary()));
-// transferAndAssert(s);
-// }
-//
-// @Test
-// public void testText() {
-// Schema t = new Schema("t").addColumn(new Text("x", 10L));
-// transferAndAssert(t);
-// }
-//
-// @Test
-// public void testTime() {
-// Schema t = new Schema("t").addColumn(new Time("t", Boolean.FALSE));
-// transferAndAssert(t);
-// }
-//
-// @Test
-// public void testUnsupported() {
-// Schema t = new Schema("t").addColumn(new Unsupported("u", 4L));
-// transferAndAssert(t);
-// }
-// @Test
-// public void testNullable() {
-// Schema nullable = new Schema("n").addColumn(new Text("x", Boolean.FALSE));
-// transferAndAssert(nullable);
-// }
-//
-// @Test
-// public void testAllTypes() {
-// Schema allTypes = new Schema("all-types")
-// .addColumn(new Array("a", new Text()))
-// .addColumn(new Binary("b"))
-// .addColumn(new Bit("c"))
-// .addColumn(new Date("d"))
-// .addColumn(new DateTime("e"))
-// .addColumn(new Decimal("f"))
-// .addColumn(new Enum("g", new Text()))
-// .addColumn(new FixedPoint("h"))
-// .addColumn(new FloatingPoint("i"))
-// .addColumn(new Map("j", new Text(), new Text()))
-// .addColumn(new Set("k", new Text()))
-// .addColumn(new Text("l"))
-// .addColumn(new Time("m"))
-// .addColumn(new Unsupported("u"))
-// ;
-// transferAndAssert(allTypes);
-// }
-//
-// @Test
-// public void testComplex() {
-// Schema complex = new Schema("complex")
-// .addColumn(new Map(new Array(new Enum(new Text())), new Set(new Array(new Text()))).setName("a"))
-// ;
-// transferAndAssert(complex);
-// }
-//
-// private void transferAndAssert(Schema schema) {
-// Schema transferred = transfer(schema);
-// assertEquals(schema, transferred);
-// }
-//
-// protected Schema transfer(Schema schema) {
-// JSONObject extractJson = SchemaSerialization.extractSchema(schema);
-//
-// String transferredString = extractJson.toJSONString();
-//
-// JSONObject restoreJson = (JSONObject) JSONValue.parse(transferredString);
-// return SchemaSerialization.restoreSchemna(restoreJson);
-// }
+ @Test
+ public void testArray() {
+ Schema array = new Schema("array").addColumn(new Array("a", new Decimal()));
+ transferAndAssert(array);
+ }
+
+ @Test
+ public void testBinary() {
+ Schema binary = new Schema("b").addColumn(new Binary("A", 100L));
+ transferAndAssert(binary);
+ }
+
+ @Test
+ public void testBit() {
+ Schema bit = new Schema("b").addColumn(new Bit("B"));
+ transferAndAssert(bit);
+ }
+
+ @Test
+ public void testDate() {
+ Schema date = new Schema("d").addColumn(new Date("d"));
+ transferAndAssert(date);
+ }
+
+ @Test
+ public void testDateTime() {
+ Schema dateTime = new Schema("dt").addColumn(new DateTime("dt", Boolean.FALSE, Boolean.TRUE));
+ transferAndAssert(dateTime);
+ }
+
+ @Test
+ public void testDecimal() {
+ Schema decimal = new Schema("d").addColumn(new Decimal("d", 12L, 15L));
+ transferAndAssert(decimal);
+ }
+
+ @Test
+ public void testEnum() {
+ Schema e = new Schema("e").addColumn(new Enum("e", new Text()));
+ transferAndAssert(e);
+ }
+
+ @Test
+ public void testFixedPoint() {
+ Schema f = new Schema("f").addColumn(new FixedPoint("fp", 4L, Boolean.FALSE));
+ transferAndAssert(f);
+ }
+
+ @Test
+ public void testFloatingPoint() {
+ Schema fp = new Schema("fp").addColumn(new FloatingPoint("k", 4L));
+ transferAndAssert(fp);
+ }
+
+ @Test
+ public void testMap() {
+ Schema m = new Schema("m").addColumn(new Map("m", new Text(), new Decimal()));
+ transferAndAssert(m);
+ }
+
+ @Test
+ public void testSet() {
+ Schema s = new Schema("s").addColumn(new Set("b", new Binary()));
+ transferAndAssert(s);
+ }
+
+ @Test
+ public void testText() {
+ Schema t = new Schema("t").addColumn(new Text("x", 10L));
+ transferAndAssert(t);
+ }
+
+ @Test
+ public void testTime() {
+ Schema t = new Schema("t").addColumn(new Time("t", Boolean.FALSE));
+ transferAndAssert(t);
+ }
+
+ @Test
+ public void testUnsupported() {
+ Schema t = new Schema("t").addColumn(new Unsupported("u", 4L));
+ transferAndAssert(t);
+ }
+ @Test
+ public void testNullable() {
+ Schema nullable = new Schema("n").addColumn(new Text("x", Boolean.FALSE));
+ transferAndAssert(nullable);
+ }
+
+ @Test
+ public void testAllTypes() {
+ Schema allTypes = new Schema("all-types")
+ .addColumn(new Array("a", new Text()))
+ .addColumn(new Binary("b"))
+ .addColumn(new Bit("c"))
+ .addColumn(new Date("d"))
+ .addColumn(new DateTime("e"))
+ .addColumn(new Decimal("f"))
+ .addColumn(new Enum("g", new Text()))
+ .addColumn(new FixedPoint("h"))
+ .addColumn(new FloatingPoint("i"))
+ .addColumn(new Map("j", new Text(), new Text()))
+ .addColumn(new Set("k", new Text()))
+ .addColumn(new Text("l"))
+ .addColumn(new Time("m"))
+ .addColumn(new Unsupported("u"))
+ ;
+ transferAndAssert(allTypes);
+ }
+
+ @Test
+ public void testComplex() {
+ Schema complex = new Schema("complex")
+ .addColumn(new Map(new Array(new Enum(new Text())), new Set(new Array(new Text()))).setName("a"))
+ ;
+ transferAndAssert(complex);
+ }
+
+ private void transferAndAssert(Schema schema) {
+ Schema transferred = transfer(schema);
+ assertEquals(schema, transferred);
+ }
+
+ protected Schema transfer(Schema schema) {
+ JSONObject extractJson = SchemaSerialization.extractSchema(schema);
+
+ String transferredString = extractJson.toJSONString();
+
+ JSONObject restoreJson = (JSONObject) JSONValue.parse(transferredString);
+ return SchemaSerialization.restoreSchemna(restoreJson);
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java b/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
index 6c76347..08dfa7b 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
@@ -32,218 +32,218 @@ import java.util.Map;
*/
public class TestFormUtils extends TestCase {
-// public void testToForms() {
-// Config config = new Config();
-// config.aForm.a1 = "value";
-//
-// List<MForm> formsByInstance = FormUtils.toForms(config);
-// assertEquals(getForms(), formsByInstance);
-// assertEquals("value", formsByInstance.get(0).getInputs().get(0).getValue());
-//
-// List<MForm> formsByClass = FormUtils.toForms(Config.class);
-// assertEquals(getForms(), formsByClass);
-//
-// List<MForm> formsByBoth = FormUtils.toForms(Config.class, config);
-// assertEquals(getForms(), formsByBoth);
-// assertEquals("value", formsByBoth.get(0).getInputs().get(0).getValue());
-// }
-//
-// public void testToFormsMissingAnnotation() {
-// try {
-// FormUtils.toForms(ConfigWithout.class);
-// } catch(SqoopException ex) {
-// assertEquals(ModelError.MODEL_003, ex.getErrorCode());
-// return;
-// }
-//
-// fail("Correct exception wasn't thrown");
-// }
-//
-// public void testFailureOnPrimitiveType() {
-// PrimitiveConfig config = new PrimitiveConfig();
-//
-// try {
-// FormUtils.toForms(config);
-// fail("We were expecting exception for unsupported type.");
-// } catch(SqoopException ex) {
-// assertEquals(ModelError.MODEL_007, ex.getErrorCode());
-// }
-// }
-//
-// public void testFillValues() {
-// List<MForm> forms = getForms();
-//
-// ((MStringInput)forms.get(0).getInputs().get(0)).setValue("value");
-//
-// Config config = new Config();
-//
-// FormUtils.fromForms(forms, config);
-// assertEquals("value", config.aForm.a1);
-// }
-//
-// public void testFillValuesObjectReuse() {
-// List<MForm> forms = getForms();
-//
-// ((MStringInput)forms.get(0).getInputs().get(0)).setValue("value");
-//
-// Config config = new Config();
-// config.aForm.a2 = "x";
-// config.bForm.b1 = "y";
-//
-// FormUtils.fromForms(forms, config);
-// assertEquals("value", config.aForm.a1);
-// assertNull(config.aForm.a2);
-// assertNull(config.bForm.b2);
-// assertNull(config.bForm.b2);
-// }
-//
-// public void testApplyValidation() {
-// Validation validation = getValidation();
-// List<MForm> forms = getForms();
-//
-// FormUtils.applyValidation(forms, validation);
-//
-// assertEquals(Status.ACCEPTABLE,
-// forms.get(0).getInputs().get(0).getValidationStatus());
-// assertEquals("e1",
-// forms.get(0).getInputs().get(0).getValidationMessage());
-//
-// assertEquals(Status.UNACCEPTABLE,
-// forms.get(0).getInputs().get(1).getValidationStatus());
-// assertEquals("e2",
-// forms.get(0).getInputs().get(1).getValidationMessage());
-// }
-//
-// public void testJson() {
-// Config config = new Config();
-// config.aForm.a1 = "A";
-// config.bForm.b2 = "B";
-// config.cForm.intValue = 4;
-// config.cForm.map.put("C", "D");
-// config.cForm.enumeration = Enumeration.X;
-//
-// String json = FormUtils.toJson(config);
-//
-// Config targetConfig = new Config();
-//
-// // Old values from should be always removed
-// targetConfig.aForm.a2 = "X";
-// targetConfig.bForm.b1 = "Y";
-// // Nulls in forms shouldn't be an issue either
-// targetConfig.cForm = null;
-//
-// FormUtils.fillValues(json, targetConfig);
-//
-// assertEquals("A", targetConfig.aForm.a1);
-// assertNull(targetConfig.aForm.a2);
-//
-// assertNull(targetConfig.bForm.b1);
-// assertEquals("B", targetConfig.bForm.b2);
-//
-// assertEquals((Integer)4, targetConfig.cForm.intValue);
-// assertEquals(1, targetConfig.cForm.map.size());
-// assertTrue(targetConfig.cForm.map.containsKey("C"));
-// assertEquals("D", targetConfig.cForm.map.get("C"));
-// assertEquals(Enumeration.X, targetConfig.cForm.enumeration);
-// }
-//
-// protected Validation getValidation() {
-// Map<Validation.FormInput, Validation.Message> messages
-// = new HashMap<Validation.FormInput, Validation.Message>();
-//
-// messages.put(
-// new Validation.FormInput("aForm", "a1"),
-// new Validation.Message(Status.ACCEPTABLE, "e1"));
-// messages.put(
-// new Validation.FormInput("aForm", "a2"),
-// new Validation.Message(Status.UNACCEPTABLE, "e2"));
-//
-// return new Validation(Status.UNACCEPTABLE, messages);
-// }
-//
-// /**
-// * Form structure that corresponds to Config class declared below
-// * @return Form structure
-// */
-// protected List<MForm> getForms() {
-// List<MForm> ret = new LinkedList<MForm>();
-//
-// List<MInput<?>> inputs;
-//
-// // Form A
-// inputs = new LinkedList<MInput<?>>();
-// inputs.add(new MStringInput("aForm.a1", false, (short)30));
-// inputs.add(new MStringInput("aForm.a2", true, (short)-1));
-// ret.add(new MForm("aForm", inputs));
-//
-// // Form B
-// inputs = new LinkedList<MInput<?>>();
-// inputs.add(new MStringInput("bForm.b1", false, (short)2));
-// inputs.add(new MStringInput("bForm.b2", false, (short)3));
-// ret.add(new MForm("bForm", inputs));
-//
-// // Form C
-// inputs = new LinkedList<MInput<?>>();
-// inputs.add(new MIntegerInput("cForm.intValue", false));
-// inputs.add(new MMapInput("cForm.map", false));
-// inputs.add(new MEnumInput("cForm.enumeration", false, new String[]{"X", "Y"}));
-// ret.add(new MForm("cForm", inputs));
-//
-// return ret;
-// }
-//
-// @ConfigurationClass
-// public static class Config {
-//
-// public Config() {
-// aForm = new AForm();
-// bForm = new BForm();
-// cForm = new CForm();
-// }
-//
-// @Form AForm aForm;
-// @Form BForm bForm;
-// @Form CForm cForm;
-// }
-//
-// @ConfigurationClass
-// public static class PrimitiveConfig {
-// @Form DForm dForm;
-// }
-//
-// @FormClass
-// public static class AForm {
-// @Input(size = 30) String a1;
-// @Input(sensitive = true) String a2;
-// }
-//
-// @FormClass
-// public static class BForm {
-// @Input(size = 2) String b1;
-// @Input(size = 3) String b2;
-// }
-//
-// @FormClass
-// public static class CForm {
-// @Input Integer intValue;
-// @Input Map<String, String> map;
-// @Input Enumeration enumeration;
-//
-// public CForm() {
-// map = new HashMap<String, String>();
-// }
-// }
-//
-// @FormClass
-// public static class DForm {
-// @Input int value;
-// }
-//
-// public static class ConfigWithout {
-// }
-//
-// enum Enumeration {
-// X,
-// Y,
-// }
+ public void testToForms() {
+ Config config = new Config();
+ config.aForm.a1 = "value";
+
+ List<MForm> formsByInstance = FormUtils.toForms(config);
+ assertEquals(getForms(), formsByInstance);
+ assertEquals("value", formsByInstance.get(0).getInputs().get(0).getValue());
+
+ List<MForm> formsByClass = FormUtils.toForms(Config.class);
+ assertEquals(getForms(), formsByClass);
+
+ List<MForm> formsByBoth = FormUtils.toForms(Config.class, config);
+ assertEquals(getForms(), formsByBoth);
+ assertEquals("value", formsByBoth.get(0).getInputs().get(0).getValue());
+ }
+
+ public void testToFormsMissingAnnotation() {
+ try {
+ FormUtils.toForms(ConfigWithout.class);
+ } catch(SqoopException ex) {
+ assertEquals(ModelError.MODEL_003, ex.getErrorCode());
+ return;
+ }
+
+ fail("Correct exception wasn't thrown");
+ }
+
+ public void testFailureOnPrimitiveType() {
+ PrimitiveConfig config = new PrimitiveConfig();
+
+ try {
+ FormUtils.toForms(config);
+ fail("We were expecting exception for unsupported type.");
+ } catch(SqoopException ex) {
+ assertEquals(ModelError.MODEL_007, ex.getErrorCode());
+ }
+ }
+
+ public void testFillValues() {
+ List<MForm> forms = getForms();
+
+ ((MStringInput)forms.get(0).getInputs().get(0)).setValue("value");
+
+ Config config = new Config();
+
+ FormUtils.fromForms(forms, config);
+ assertEquals("value", config.aForm.a1);
+ }
+
+ public void testFillValuesObjectReuse() {
+ List<MForm> forms = getForms();
+
+ ((MStringInput)forms.get(0).getInputs().get(0)).setValue("value");
+
+ Config config = new Config();
+ config.aForm.a2 = "x";
+ config.bForm.b1 = "y";
+
+ FormUtils.fromForms(forms, config);
+ assertEquals("value", config.aForm.a1);
+ assertNull(config.aForm.a2);
+ assertNull(config.bForm.b2);
+ assertNull(config.bForm.b2);
+ }
+
+ public void testApplyValidation() {
+ Validation validation = getValidation();
+ List<MForm> forms = getForms();
+
+ FormUtils.applyValidation(forms, validation);
+
+ assertEquals(Status.ACCEPTABLE,
+ forms.get(0).getInputs().get(0).getValidationStatus());
+ assertEquals("e1",
+ forms.get(0).getInputs().get(0).getValidationMessage());
+
+ assertEquals(Status.UNACCEPTABLE,
+ forms.get(0).getInputs().get(1).getValidationStatus());
+ assertEquals("e2",
+ forms.get(0).getInputs().get(1).getValidationMessage());
+ }
+
+ public void testJson() {
+ Config config = new Config();
+ config.aForm.a1 = "A";
+ config.bForm.b2 = "B";
+ config.cForm.intValue = 4;
+ config.cForm.map.put("C", "D");
+ config.cForm.enumeration = Enumeration.X;
+
+ String json = FormUtils.toJson(config);
+
+ Config targetConfig = new Config();
+
+ // Old values from should be always removed
+ targetConfig.aForm.a2 = "X";
+ targetConfig.bForm.b1 = "Y";
+ // Nulls in forms shouldn't be an issue either
+ targetConfig.cForm = null;
+
+ FormUtils.fillValues(json, targetConfig);
+
+ assertEquals("A", targetConfig.aForm.a1);
+ assertNull(targetConfig.aForm.a2);
+
+ assertNull(targetConfig.bForm.b1);
+ assertEquals("B", targetConfig.bForm.b2);
+
+ assertEquals((Integer)4, targetConfig.cForm.intValue);
+ assertEquals(1, targetConfig.cForm.map.size());
+ assertTrue(targetConfig.cForm.map.containsKey("C"));
+ assertEquals("D", targetConfig.cForm.map.get("C"));
+ assertEquals(Enumeration.X, targetConfig.cForm.enumeration);
+ }
+
+ protected Validation getValidation() {
+ Map<Validation.FormInput, Validation.Message> messages
+ = new HashMap<Validation.FormInput, Validation.Message>();
+
+ messages.put(
+ new Validation.FormInput("aForm", "a1"),
+ new Validation.Message(Status.ACCEPTABLE, "e1"));
+ messages.put(
+ new Validation.FormInput("aForm", "a2"),
+ new Validation.Message(Status.UNACCEPTABLE, "e2"));
+
+ return new Validation(Status.UNACCEPTABLE, messages);
+ }
+
+ /**
+ * Form structure that corresponds to Config class declared below
+ * @return Form structure
+ */
+ protected List<MForm> getForms() {
+ List<MForm> ret = new LinkedList<MForm>();
+
+ List<MInput<?>> inputs;
+
+ // Form A
+ inputs = new LinkedList<MInput<?>>();
+ inputs.add(new MStringInput("aForm.a1", false, (short)30));
+ inputs.add(new MStringInput("aForm.a2", true, (short)-1));
+ ret.add(new MForm("aForm", inputs));
+
+ // Form B
+ inputs = new LinkedList<MInput<?>>();
+ inputs.add(new MStringInput("bForm.b1", false, (short)2));
+ inputs.add(new MStringInput("bForm.b2", false, (short)3));
+ ret.add(new MForm("bForm", inputs));
+
+ // Form C
+ inputs = new LinkedList<MInput<?>>();
+ inputs.add(new MIntegerInput("cForm.intValue", false));
+ inputs.add(new MMapInput("cForm.map", false));
+ inputs.add(new MEnumInput("cForm.enumeration", false, new String[]{"X", "Y"}));
+ ret.add(new MForm("cForm", inputs));
+
+ return ret;
+ }
+
+ @ConfigurationClass
+ public static class Config {
+
+ public Config() {
+ aForm = new AForm();
+ bForm = new BForm();
+ cForm = new CForm();
+ }
+
+ @Form AForm aForm;
+ @Form BForm bForm;
+ @Form CForm cForm;
+ }
+
+ @ConfigurationClass
+ public static class PrimitiveConfig {
+ @Form DForm dForm;
+ }
+
+ @FormClass
+ public static class AForm {
+ @Input(size = 30) String a1;
+ @Input(sensitive = true) String a2;
+ }
+
+ @FormClass
+ public static class BForm {
+ @Input(size = 2) String b1;
+ @Input(size = 3) String b2;
+ }
+
+ @FormClass
+ public static class CForm {
+ @Input Integer intValue;
+ @Input Map<String, String> map;
+ @Input Enumeration enumeration;
+
+ public CForm() {
+ map = new HashMap<String, String>();
+ }
+ }
+
+ @FormClass
+ public static class DForm {
+ @Input int value;
+ }
+
+ public static class ConfigWithout {
+ }
+
+ enum Enumeration {
+ X,
+ Y,
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 942a056..f3d4166 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
@@ -30,32 +30,32 @@ import org.junit.Test;
*/
public class TestMAccountableEntity {
-// /**
-// * Test for class initialization
-// */
-// @Test
-// public void testInitialization() {
-// List<MForm> forms = new ArrayList<MForm>();
-// MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
-// List<MInput<?>> list = new ArrayList<MInput<?>>();
-// list.add(input);
-// MForm form = new MForm("FORMNAME", list);
-// forms.add(form);
-// MAccountableEntity connection = new MConnection(123l, new MConnectionForms(
-// forms), new MConnectionForms(forms));
-// // Initially creation date and last update date is same
-// assertEquals(connection.getCreationDate(), connection.getLastUpdateDate());
-// Date testCreationDate = new Date();
-// Date testLastUpdateDate = new Date();
-// connection.setCreationUser("admin");
-// connection.setCreationDate(testCreationDate);
-// connection.setLastUpdateUser("user");
-// connection.setLastUpdateDate(testLastUpdateDate);
-// connection.setEnabled(false);
-// assertEquals(testCreationDate, connection.getCreationDate());
-// assertEquals("admin", connection.getCreationUser());
-// assertEquals(testLastUpdateDate, connection.getLastUpdateDate());
-// assertEquals(false, connection.getEnabled());
-// assertEquals("user", connection.getLastUpdateUser());
-// }
+ /**
+ * Test for class initialization
+ */
+ @Test
+ public void testInitialization() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
+ List<MInput<?>> list = new ArrayList<MInput<?>>();
+ list.add(input);
+ MForm form = new MForm("FORMNAME", list);
+ forms.add(form);
+ MAccountableEntity connection = new MConnection(123l, new MConnectionForms(
+ forms), new MConnectionForms(forms));
+ // Initially creation date and last update date is same
+ assertEquals(connection.getCreationDate(), connection.getLastUpdateDate());
+ Date testCreationDate = new Date();
+ Date testLastUpdateDate = new Date();
+ connection.setCreationUser("admin");
+ connection.setCreationDate(testCreationDate);
+ connection.setLastUpdateUser("user");
+ connection.setLastUpdateDate(testLastUpdateDate);
+ connection.setEnabled(false);
+ assertEquals(testCreationDate, connection.getCreationDate());
+ assertEquals("admin", connection.getCreationUser());
+ assertEquals(testLastUpdateDate, connection.getLastUpdateDate());
+ assertEquals(false, connection.getEnabled());
+ assertEquals("user", connection.getLastUpdateUser());
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bb7ff83/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 b955aa4..cf9cf24 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMBooleanInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMBooleanInput.java
@@ -30,70 +30,70 @@ import static org.junit.Assert.assertTrue;
*/
public class TestMBooleanInput {
-// /**
-// * Test for class initialization
-// */
-// @Test
-// public void testInitialization() {
-// MBooleanInput input = new MBooleanInput("sqoopsqoop", true);
-// assertEquals("sqoopsqoop", input.getName());
-// assertEquals(true, input.isSensitive());
-// assertEquals(MInputType.BOOLEAN, input.getType());
-// }
-//
-// /**
-// * Test for equals() method
-// */
-// @Test
-// public void testEquals() {
-// // Positive test
-// MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
-// MBooleanInput input2 = new MBooleanInput("sqoopsqoop", true);
-// assertTrue(input1.equals(input2));
-//
-// // Negative test
-// MBooleanInput input3 = new MBooleanInput("sqoopsqoop", false);
-// MBooleanInput input4 = new MBooleanInput("sqoopsqoop", true);
-// assertFalse(input3.equals(input4));
-//
-// MBooleanInput input5 = new MBooleanInput("sqoopsqoop", false);
-// MBooleanInput input6 = new MBooleanInput("sqoop", false);
-// assertFalse(input5.equals(input6));
-// }
-//
-// /**
-// * Test for value
-// */
-// @Test
-// public void testValue() {
-// MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
-// input1.setValue(true);
-// assertEquals(true, input1.getValue());
-// input1.setEmpty();
-// assertNull(input1.getValue());
-// }
-//
-// /**
-// * Test for getUrlSafeValueString() and restoreFromUrlSafeValueString()
-// */
-// @Test
-// public void testUrlSafe() {
-// MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
-// input1.setValue(true);
-// // Getting URL safe string
-// String tmp = input1.getUrlSafeValueString();
-// // Restore to actual value
-// input1.restoreFromUrlSafeValueString(tmp);
-// assertEquals(true, input1.getValue());
-// }
-//
-// /**
-// * Test case for MNamedElement.getLabelKey() and MNamedElement.getHelpKey()
-// */
-// @Test
-// public void testNamedElement() {
-// MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
-// assertEquals("sqoopsqoop.label", input1.getLabelKey());
-// assertEquals("sqoopsqoop.help", input1.getHelpKey());
-// }
+ /**
+ * Test for class initialization
+ */
+ @Test
+ public void testInitialization() {
+ MBooleanInput input = new MBooleanInput("sqoopsqoop", true);
+ assertEquals("sqoopsqoop", input.getName());
+ assertEquals(true, input.isSensitive());
+ assertEquals(MInputType.BOOLEAN, input.getType());
+ }
+
+ /**
+ * Test for equals() method
+ */
+ @Test
+ public void testEquals() {
+ // Positive test
+ MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
+ MBooleanInput input2 = new MBooleanInput("sqoopsqoop", true);
+ assertTrue(input1.equals(input2));
+
+ // Negative test
+ MBooleanInput input3 = new MBooleanInput("sqoopsqoop", false);
+ MBooleanInput input4 = new MBooleanInput("sqoopsqoop", true);
+ assertFalse(input3.equals(input4));
+
+ MBooleanInput input5 = new MBooleanInput("sqoopsqoop", false);
+ MBooleanInput input6 = new MBooleanInput("sqoop", false);
+ assertFalse(input5.equals(input6));
+ }
+
+ /**
+ * Test for value
+ */
+ @Test
+ public void testValue() {
+ MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
+ input1.setValue(true);
+ assertEquals(true, input1.getValue());
+ input1.setEmpty();
+ assertNull(input1.getValue());
+ }
+
+ /**
+ * Test for getUrlSafeValueString() and restoreFromUrlSafeValueString()
+ */
+ @Test
+ public void testUrlSafe() {
+ MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
+ input1.setValue(true);
+ // Getting URL safe string
+ String tmp = input1.getUrlSafeValueString();
+ // Restore to actual value
+ input1.restoreFromUrlSafeValueString(tmp);
+ assertEquals(true, input1.getValue());
+ }
+
+ /**
+ * Test case for MNamedElement.getLabelKey() and MNamedElement.getHelpKey()
+ */
+ @Test
+ public void testNamedElement() {
+ MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true);
+ assertEquals("sqoopsqoop.label", input1.getLabelKey());
+ assertEquals("sqoopsqoop.help", input1.getHelpKey());
+ }
}