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 2013/01/17 10:50:52 UTC
git commit: SQOOP-831: Unit test for common module
Updated Branches:
refs/heads/sqoop2 694d181df -> 7b097a97a
SQOOP-831: Unit test for common module
(Vasanth kumar RJ 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/7b097a97
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/7b097a97
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/7b097a97
Branch: refs/heads/sqoop2
Commit: 7b097a97a895a4d1b6d0e4cce3c828597a3195af
Parents: 694d181
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Thu Jan 17 01:50:08 2013 -0800
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Thu Jan 17 01:50:08 2013 -0800
----------------------------------------------------------------------
.../org/apache/sqoop/common/TestMapContext.java | 110 +++++++++++
.../apache/sqoop/common/TestSqoopResponseCode.java | 41 ++++
.../apache/sqoop/model/TestMAccountableEntity.java | 55 ++++++
.../org/apache/sqoop/model/TestMConnection.java | 68 +++++++
.../apache/sqoop/model/TestMConnectionForms.java | 48 +++++
.../org/apache/sqoop/model/TestMConnector.java | 67 +++++++
.../org/apache/sqoop/model/TestMEnumInput.java | 45 +++++
.../java/org/apache/sqoop/model/TestMForm.java | 68 +++++++
.../org/apache/sqoop/model/TestMIntegerInput.java | 92 +++++++++
.../test/java/org/apache/sqoop/model/TestMJob.java | 48 +++++
.../java/org/apache/sqoop/model/TestMJobForms.java | 47 +++++
.../java/org/apache/sqoop/model/TestMMapInput.java | 97 ++++++++++
.../org/apache/sqoop/model/TestMNamedElement.java | 39 ++++
.../org/apache/sqoop/model/TestMStringInput.java | 95 ++++++++++
.../apache/sqoop/model/TestMValidatedElement.java | 70 +++++++
.../sqoop/submission/TestSubmissionStatus.java | 64 +++++++
.../sqoop/submission/counter/TestCounter.java | 44 +++++
.../sqoop/submission/counter/TestCounterGroup.java | 81 ++++++++
.../sqoop/submission/counter/TestCounters.java | 67 +++++++
.../apache/sqoop/validation/TestValidation.java | 145 +++++++++++++++
20 files changed, 1391 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..f4718c0
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/common/TestMapContext.java
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.common;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.common.MapContext
+ */
+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"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..f556c1c
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/common/TestSqoopResponseCode.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.common;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.common.SqoopResponseCode
+ */
+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());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..1cde5cf
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.MAccountableEntity
+ */
+public class TestMAccountableEntity {
+
+ /**
+ * Test for class initialization
+ */
+ @Test
+ public void testInitialization() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MIntegerInput input = new MIntegerInput("INTEGER-INPUT");
+ 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.setCreationDate(testCreationDate);
+ connection.setLastUpdateDate(testLastUpdateDate);
+ assertEquals(testCreationDate, connection.getCreationDate());
+ assertEquals(testLastUpdateDate, connection.getLastUpdateDate());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..d5f9f38
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.MConnection
+ */
+public class TestMConnection {
+
+ /**
+ * Test for initialization
+ */
+ @Test
+ public void testInitialization() {
+ MConnectionForms connectorPart = connector1();
+ MConnectionForms frameworkPart = connector2();
+ MConnection connection = new MConnection(123l, connectorPart, frameworkPart);
+ assertEquals(123l, connection.getConnectorId());
+ assertEquals(connector1(), connection.getConnectorPart());
+ assertEquals(connector2(), connection.getFrameworkPart());
+ assertFalse(connector1().equals(connection.getFrameworkPart()));
+ connection.setName("NAME");
+ assertEquals("NAME", connection.getName());
+ }
+
+ private MConnectionForms connector1() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MIntegerInput input = new MIntegerInput("INTEGER-INPUT");
+ List<MInput<?>> list = new ArrayList<MInput<?>>();
+ list.add(input);
+ MForm form = new MForm("FORMNAME", list);
+ forms.add(form);
+ return new MConnectionForms(forms);
+ }
+
+ private MConnectionForms connector2() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MMapInput input = new MMapInput("MAP-INPUT");
+ 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/7b097a97/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
new file mode 100644
index 0000000..e2d2717
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.MConnectionForms
+ */
+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));
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..716b124
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.TestMConnector
+ */
+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);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..0a3392c
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.MEnumInput
+ */
+public class TestMEnumInput {
+ /**
+ * Test for class initialization
+ */
+ @Test
+ public void testInitialization() {
+ String[] values = { "value1", "value2" };
+ MEnumInput input = new MEnumInput("NAME", values);
+ assertEquals("NAME", input.getName());
+ assertArrayEquals(values, input.getValues());
+ assertEquals(MInputType.ENUM, input.getType());
+
+ MEnumInput input1 = new MEnumInput("NAME", values);
+ assertEquals(input1, input);
+ String[] testVal = { "val", "test" };
+ MEnumInput input2 = new MEnumInput("NAME1", testVal);
+ assertFalse(input1.equals(input2));
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..38443a7
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMForm.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.MForm
+ */
+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");
+ MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2");
+ List<MInput<?>> list1 = new ArrayList<MInput<?>>();
+ list1.add(input1);
+ list1.add(input2);
+ MForm mform1 = new MForm("form", list1);
+
+ MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1");
+ MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2");
+ List<MInput<?>> list2 = new ArrayList<MInput<?>>();
+ list2.add(input3);
+ list2.add(input4);
+ MForm mform2 = new MForm("form", list2);
+ assertEquals(mform2, mform1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..042158a
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+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");
+ assertEquals("sqoopsqoop", input.getName());
+ assertEquals(MInputType.INTEGER, input.getType());
+ }
+
+ /**
+ * Test for equals() method
+ */
+ @Test
+ public void testEquals() {
+ // Positive test
+ MIntegerInput input1 = new MIntegerInput("sqoopsqoop");
+ MIntegerInput input2 = new MIntegerInput("sqoopsqoop");
+ assertTrue(input1.equals(input2));
+
+ // Negative test
+ MIntegerInput input3 = new MIntegerInput("sqoopsqoop");
+ MIntegerInput input4 = new MIntegerInput("sqoopsqoop1");
+ assertFalse(input3.equals(input4));
+ }
+
+ /**
+ * Test for value
+ */
+ @Test
+ public void testValue() {
+ MIntegerInput input1 = new MIntegerInput("sqoopsqoop");
+ 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");
+ 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());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..dbc791e
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.MJob
+ */
+public class TestMJob {
+ /**
+ * Test class for initialization
+ */
+ @Test
+ public void testInitialization() {
+ List<MForm> forms = new ArrayList<MForm>();
+ MJobForms jobform1 = new MJobForms(MJob.Type.EXPORT, forms);
+ List<MForm> forms2 = new ArrayList<MForm>();
+ MJobForms jobform2 = new MJobForms(MJob.Type.EXPORT, forms2);
+ MJob job = new MJob(123l, 456l, MJob.Type.EXPORT, jobform1, jobform2);
+
+ assertEquals(123l, job.getConnectorId());
+ assertEquals(456l, job.getConnectionId());
+ assertEquals(MJob.Type.EXPORT, job.getType());
+ assertEquals(jobform1, job.getConnectorPart());
+ assertEquals(jobform2, job.getFrameworkPart());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..b2bb0a5
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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));
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..772f230
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+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");
+ assertEquals("sqoopsqoop", input.getName());
+ assertEquals(MInputType.MAP, input.getType());
+ }
+
+ /**
+ * Test for equals() method
+ */
+ @Test
+ public void testEquals() {
+ // Positive test
+ MMapInput input1 = new MMapInput("sqoopsqoop");
+ MMapInput input2 = new MMapInput("sqoopsqoop");
+ assertTrue(input1.equals(input2));
+
+ // Negative test
+ MMapInput input3 = new MMapInput("sqoopsqoop");
+ MMapInput input4 = new MMapInput("sqoopsqoop1");
+ assertFalse(input3.equals(input4));
+ }
+
+ /**
+ * Test for value
+ */
+ @Test
+ public void testValue() {
+ MMapInput input1 = new MMapInput("sqoopsqoop");
+ 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");
+ 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);
+ assertEquals(null, 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/7b097a97/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
new file mode 100644
index 0000000..fa6b9ad
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.MNamedElement
+ */
+public class TestMNamedElement {
+
+ /**
+ * Test initialization and values
+ */
+ @Test
+ public void testInitialization() {
+ MNamedElement named = new MIntegerInput("SQOOP");
+ assertEquals("SQOOP", named.getName());
+ assertEquals("SQOOP.label", named.getLabelKey());
+ assertEquals("SQOOP.help", named.getHelpKey());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..2ba9709
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.MStringInput
+ */
+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.isMasked());
+ 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/7b097a97/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
new file mode 100644
index 0000000..8d07521
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import static org.junit.Assert.*;
+
+import org.apache.sqoop.validation.Status;
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.model.MValidatedElement
+ */
+public class TestMValidatedElement {
+
+ /**
+ * Test for initalization
+ */
+ @Test
+ public void testInitialization() {
+ MValidatedElement input = new MIntegerInput("input");
+ assertEquals("input", input.getName());
+ assertEquals(Status.FINE, input.getValidationStatus());
+ }
+
+ /**
+ * Test for validation message and status
+ */
+ @Test
+ public void testValidationMessageStatus() {
+ MValidatedElement input = new MIntegerInput("input");
+ // 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/7b097a97/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
new file mode 100644
index 0000000..99f4767
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/submission/TestSubmissionStatus.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.submission;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Test class for org.apache.sqoop.submission.SubmissionStatus
+ */
+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());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..0cf5d2b
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/submission/counter/TestCounter.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.submission.counter;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.submission.counter.Counter
+ */
+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());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..985009a
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/submission/counter/TestCounterGroup.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.submission.counter;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+/**
+ * Test class for org.apache.sqoop.submission.counter.CounterGroup
+ */
+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);
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..8f8d617
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/submission/counter/TestCounters.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.submission.counter;
+
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+/**
+ * Test Class for org.apache.sqoop.submission.counter.TestCounters
+ */
+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);
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/7b097a97/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
new file mode 100644
index 0000000..600cfff
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
@@ -0,0 +1,145 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.validation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.validation.Validation.FormInput;
+import org.apache.sqoop.validation.Validation.Message;
+
+/**
+ * Test class for org.apache.sqoop.validation.Validation
+ */
+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);
+
+ Validation.FormInput fi1;
+ /** Passing null */
+ try {
+ fi1 = new Validation.FormInput(null);
+ fail("Null pointer exception is expected");
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ }
+
+ /** Passing empty string and check for SqoopException */
+ try {
+ fi1 = new Validation.FormInput("");
+ fail("SqoopException is expected");
+ } catch (SqoopException e) {
+ assertTrue(true);
+ }
+
+ /** Passing empty and check exception messages */
+ try {
+ fi1 = 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());
+ }
+
+ /**
+ * 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);
+ }
+}