diff --git a/client/pom.xml b/client/pom.xml index d424e8d9..a86516b0 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -33,8 +33,8 @@ limitations under the License. - junit - junit + org.testng + testng test diff --git a/client/src/test/java/org/apache/sqoop/client/TestSqoopClient.java b/client/src/test/java/org/apache/sqoop/client/TestSqoopClient.java index 18b6132f..91e34c19 100644 --- a/client/src/test/java/org/apache/sqoop/client/TestSqoopClient.java +++ b/client/src/test/java/org/apache/sqoop/client/TestSqoopClient.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.client; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -45,15 +45,15 @@ import org.apache.sqoop.model.MLinkConfig; import org.apache.sqoop.model.MToConfig; import org.apache.sqoop.utils.MapResourceBundle; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; public class TestSqoopClient { SqoopResourceRequests resourceRequests; SqoopClient client; - @Before + @BeforeMethod public void setUp() { resourceRequests = mock(SqoopResourceRequests.class); client = new SqoopClient("my-cool-server"); @@ -199,7 +199,7 @@ public void testGetConnectorOneByOne() { /** * Link for non-existing connector can't be created. */ - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testCreateLink() { when(resourceRequests.readConnector(null)).thenReturn(connectorBean(connector(1))); client.createLink("non existing connector"); diff --git a/common-test/pom.xml b/common-test/pom.xml index 2d63f729..d08951b3 100644 --- a/common-test/pom.xml +++ b/common-test/pom.xml @@ -36,8 +36,8 @@ limitations under the License. - junit - junit + org.testng + testng diff --git a/common-test/src/main/java/org/apache/sqoop/common/test/asserts/ProviderAsserts.java b/common-test/src/main/java/org/apache/sqoop/common/test/asserts/ProviderAsserts.java index 8196fe2e..fb4e7af4 100644 --- a/common-test/src/main/java/org/apache/sqoop/common/test/asserts/ProviderAsserts.java +++ b/common-test/src/main/java/org/apache/sqoop/common/test/asserts/ProviderAsserts.java @@ -23,8 +23,8 @@ import java.sql.ResultSet; import java.sql.SQLException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.fail; /** * Database provider related asserts. diff --git a/common-test/src/main/java/org/apache/sqoop/common/test/categories/SlowTests.java b/common-test/src/main/java/org/apache/sqoop/common/test/categories/SlowTests.java deleted file mode 100644 index f8ce4747..00000000 --- a/common-test/src/main/java/org/apache/sqoop/common/test/categories/SlowTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sqoop.common.test.categories; - -/** - * Slow tests interface for JUnit categories. - * This should be used if your unit tests rely on - * some piece of infrastructure that takes time to start. - * For example, using a MySQL database takes time to setup - * and start because it is in a separate process. - */ -public interface SlowTests {} diff --git a/common/pom.xml b/common/pom.xml index e8a8010e..af0a404e 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -41,8 +41,8 @@ limitations under the License. json-simple - junit - junit + org.testng + testng test 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 7ce1ccd2..f9ed37bb 100644 --- a/common/src/test/java/org/apache/sqoop/common/TestMapContext.java +++ b/common/src/test/java/org/apache/sqoop/common/TestMapContext.java @@ -20,8 +20,8 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.Test; /** * Test class for org.apache.sqoop.common.MapContext 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 f556c1c8..8dc26049 100644 --- a/common/src/test/java/org/apache/sqoop/common/TestSqoopResponseCode.java +++ b/common/src/test/java/org/apache/sqoop/common/TestSqoopResponseCode.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.common; -import org.junit.Assert; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.Test; /** * Test class for org.apache.sqoop.common.SqoopResponseCode diff --git a/common/src/test/java/org/apache/sqoop/common/TestSupportedDirections.java b/common/src/test/java/org/apache/sqoop/common/TestSupportedDirections.java index 4f0cdd67..7fe0c088 100644 --- a/common/src/test/java/org/apache/sqoop/common/TestSupportedDirections.java +++ b/common/src/test/java/org/apache/sqoop/common/TestSupportedDirections.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.common; -import org.junit.Assert; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.Test; public class TestSupportedDirections { 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 43575dac..89d1dccf 100644 --- a/common/src/test/java/org/apache/sqoop/common/TestVersionInfo.java +++ b/common/src/test/java/org/apache/sqoop/common/TestVersionInfo.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.common; -import org.junit.Assert; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.Test; public class TestVersionInfo { 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 44d7dd99..f328e939 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.json; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; import java.util.HashMap; import java.util.LinkedList; @@ -30,7 +30,7 @@ import org.apache.sqoop.json.util.ConfigTestUtil; import org.apache.sqoop.model.MConnector; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; public class TestConnectorBean { diff --git a/common/src/test/java/org/apache/sqoop/json/TestConnectorsBean.java b/common/src/test/java/org/apache/sqoop/json/TestConnectorsBean.java index b4370e64..77b8f521 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestConnectorsBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestConnectorsBean.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.json; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; import java.util.HashMap; import java.util.LinkedList; @@ -30,7 +30,7 @@ import org.apache.sqoop.json.util.ConfigTestUtil; import org.apache.sqoop.model.MConnector; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; public class TestConnectorsBean { diff --git a/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java b/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java index b72c432b..9297533d 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java @@ -17,14 +17,14 @@ */ package org.apache.sqoop.json; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import java.util.ResourceBundle; import org.apache.sqoop.json.util.ConfigTestUtil; import org.apache.sqoop.model.MDriver; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; /** * diff --git a/common/src/test/java/org/apache/sqoop/json/TestJSONUtils.java b/common/src/test/java/org/apache/sqoop/json/TestJSONUtils.java index 7efee21f..4e80ec70 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestJSONUtils.java +++ b/common/src/test/java/org/apache/sqoop/json/TestJSONUtils.java @@ -19,12 +19,12 @@ import org.apache.sqoop.common.SqoopException; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; import java.io.Reader; import java.io.StringReader; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** */ @@ -36,12 +36,12 @@ public void testString() { assertEquals((long)3, object.get("id")); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testStringInvalid() { JSONUtils.parse("{"); } - @Test(expected = NullPointerException.class) + @Test(expectedExceptions = NullPointerException.class) public void testStringNull() { JSONUtils.parse((String)null); } @@ -52,12 +52,12 @@ public void testReader() { assertEquals((long)3, object.get("id")); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testReaderInvalid() { JSONUtils.parse(new StringReader("{")); } - @Test(expected = NullPointerException.class) + @Test(expectedExceptions = NullPointerException.class) public void testReaderNull() { JSONUtils.parse((Reader)null); } 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 98cfee84..68a4ca76 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java @@ -17,7 +17,7 @@ */ package org.apache.sqoop.json; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import java.util.Date; @@ -27,7 +27,7 @@ import org.apache.sqoop.model.MStringInput; import org.json.simple.JSONObject; import org.json.simple.parser.ParseException; -import org.junit.Test; +import org.testng.annotations.Test; public class TestJobBean { diff --git a/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java b/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java index 42fbf9d1..2dffb060 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java @@ -17,7 +17,7 @@ */ package org.apache.sqoop.json; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import java.util.ArrayList; import java.util.Date; @@ -29,7 +29,7 @@ import org.apache.sqoop.model.MStringInput; import org.json.simple.JSONObject; import org.json.simple.parser.ParseException; -import org.junit.Test; +import org.testng.annotations.Test; public class TestJobsBean { diff --git a/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java b/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java index 704e4da4..ac2c824e 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.json; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; import java.util.Date; @@ -29,7 +29,7 @@ import org.apache.sqoop.model.MStringInput; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; public class TestLinkBean { diff --git a/common/src/test/java/org/apache/sqoop/json/TestLinksBean.java b/common/src/test/java/org/apache/sqoop/json/TestLinksBean.java index 9633c5e3..c6b10072 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestLinksBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestLinksBean.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.json; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Date; @@ -30,7 +30,7 @@ import org.apache.sqoop.model.MStringInput; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; public class TestLinksBean { diff --git a/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java index 24c0b349..abbfbb41 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java @@ -27,14 +27,14 @@ import org.apache.sqoop.submission.counter.CounterGroup; import org.apache.sqoop.submission.counter.Counters; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.ArrayList; import java.util.Date; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; // NOTE: This tests both the submission and submissions list bean public class TestSubmissionBean { diff --git a/common/src/test/java/org/apache/sqoop/json/TestThrowableBean.java b/common/src/test/java/org/apache/sqoop/json/TestThrowableBean.java index a67283cd..d7ebf54c 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestThrowableBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestThrowableBean.java @@ -20,11 +20,11 @@ import org.apache.sqoop.common.SqoopException; import org.apache.sqoop.json.util.SerializationError; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; /** * diff --git a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java index c119e02c..1ba78c8d 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java @@ -21,16 +21,16 @@ import org.apache.sqoop.validation.Status; import org.apache.sqoop.validation.ConfigValidationResult; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.LinkedList; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; /** */ diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java index 9ae764a4..10ac3cfe 100644 --- a/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java +++ b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.json.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; import java.util.HashMap; import java.util.LinkedList; @@ -36,7 +36,7 @@ import org.apache.sqoop.model.MMapInput; import org.apache.sqoop.model.MStringInput; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; /** * @@ -72,7 +72,7 @@ public void testAllDataTypes() { 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(true, retrieved.getBooleanInput("Boolean").getValue().booleanValue()); assertEquals("YES", retrieved.getEnumInput("Enum").getValue()); } @@ -95,7 +95,7 @@ public void testMapDataType() { assertEquals(map, retrieved.getMapInput("Map").getValue()); } - @Test(expected=SqoopException.class) + @Test(expectedExceptions=SqoopException.class) public void testMapDataTypeException() { MConfig config = getMapConfig(); 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 9031c997..0cb7175b 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 @@ -17,7 +17,7 @@ */ package org.apache.sqoop.json.util; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import java.util.Arrays; import java.util.Collections; @@ -43,7 +43,7 @@ import org.apache.sqoop.schema.type.Time; import org.apache.sqoop.schema.type.Unknown; import org.json.simple.JSONObject; -import org.junit.Test; +import org.testng.annotations.Test; /** * @@ -64,25 +64,25 @@ public void testNullSchemaObject() { } @SuppressWarnings("unused") - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testEmptySchemaName() { Schema schema = new Schema(""); } @SuppressWarnings("unused") - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testNullSchemaName() { Schema schema = new Schema(null); } @SuppressWarnings("unused") - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testSchemaWithNullColumnName() { Schema schema = new Schema("test").addColumn(new Text(null)); } @SuppressWarnings("unused") - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testSchemaWithEmptyColumnName() { Schema schema = new Schema("test").addColumn(new Text("")); } 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 ba537395..c0644e72 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java @@ -21,9 +21,9 @@ import java.util.Date; import java.util.List; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** * Test class for org.apache.sqoop.model.MAccountableEntity 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 433c1607..57d2da2a 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMBooleanInput.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMBooleanInput.java @@ -17,12 +17,12 @@ */ package org.apache.sqoop.model; -import org.junit.Test; +import org.testng.annotations.Test; -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 static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; /** * Test class for org.apache.sqoop.model.MBooleanInput @@ -67,7 +67,7 @@ public void testEquals() { public void testValue() { MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true); input1.setValue(true); - assertEquals(true, input1.getValue()); + assertEquals(true, input1.getValue().booleanValue()); input1.setEmpty(); assertNull(input1.getValue()); } @@ -83,7 +83,7 @@ public void testUrlSafe() { String tmp = input1.getUrlSafeValueString(); // Restore to actual value input1.restoreFromUrlSafeValueString(tmp); - assertEquals(true, input1.getValue()); + assertEquals(true, input1.getValue().booleanValue()); } /** diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConfig.java b/common/src/test/java/org/apache/sqoop/model/TestMConfig.java index c5a07a02..908348da 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMConfig.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMConfig.java @@ -20,9 +20,9 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.*; public class TestMConfig { diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java b/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java index 46f4f813..4f8261c5 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java @@ -17,13 +17,13 @@ */ package org.apache.sqoop.model; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; public class TestMConfigList { @Test 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 89ae440c..e1c02aad 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMConnector.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMConnector.java @@ -17,19 +17,19 @@ */ package org.apache.sqoop.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.sqoop.common.Direction; -import org.junit.Test; +import org.testng.annotations.Test; public class TestMConnector { diff --git a/common/src/test/java/org/apache/sqoop/model/TestMDriver.java b/common/src/test/java/org/apache/sqoop/model/TestMDriver.java index aa1ee346..3acb27e7 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMDriver.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMDriver.java @@ -17,13 +17,13 @@ */ package org.apache.sqoop.model; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import java.util.ArrayList; import java.util.List; import org.apache.sqoop.json.DriverBean; -import org.junit.Test; +import org.testng.annotations.Test; public class TestMDriver { 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 c76d0313..39f09ce0 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.model; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.AssertJUnit.*; /** * Test class for org.apache.sqoop.model.MEnumInput 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 dd9227e4..69e511f4 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java @@ -17,12 +17,12 @@ */ package org.apache.sqoop.model; -import org.junit.Test; +import org.testng.annotations.Test; -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 static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; /** * Test class for org.apache.sqoop.model.MInputInput 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 848c2cce..605f429b 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMJob.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMJob.java @@ -17,14 +17,14 @@ */ package org.apache.sqoop.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNull; import java.util.ArrayList; import java.util.List; import org.apache.sqoop.common.Direction; -import org.junit.Test; +import org.testng.annotations.Test; public class TestMJob { /** diff --git a/common/src/test/java/org/apache/sqoop/model/TestMJobConfig.java b/common/src/test/java/org/apache/sqoop/model/TestMJobConfig.java index 7d0641e2..bc69c6c8 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMJobConfig.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMJobConfig.java @@ -20,9 +20,9 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.*; public class TestMJobConfig { /** diff --git a/common/src/test/java/org/apache/sqoop/model/TestMLink.java b/common/src/test/java/org/apache/sqoop/model/TestMLink.java index 9ad89546..e985c179 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMLink.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMLink.java @@ -20,9 +20,9 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.*; public class TestMLink { diff --git a/common/src/test/java/org/apache/sqoop/model/TestMLinkConfig.java b/common/src/test/java/org/apache/sqoop/model/TestMLinkConfig.java index 62f61a64..7056f496 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMLinkConfig.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMLinkConfig.java @@ -20,9 +20,9 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.*; public class TestMLinkConfig { 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 fbc08c70..c9b786be 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java @@ -20,13 +20,13 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; /** * Test class for org.apache.sqoop.model.MMapInput 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 66107847..f851cbd1 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.model; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.*; /** * Test class for org.apache.sqoop.model.MNamedElement 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 8e1e5bd3..8710eb24 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMPersistableEntity.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMPersistableEntity.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.model; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.*; public class TestMPersistableEntity { 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 76e625e9..a4faf954 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.model; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.*; /** * Test class for org.apache.sqoop.model.MStringInput 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 3db261ac..f0bdda4b 100644 --- a/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java +++ b/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java @@ -19,9 +19,9 @@ import org.apache.sqoop.validation.Message; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.*; /** * Test class for org.apache.sqoop.model.MValidatedElement diff --git a/common/src/test/java/org/apache/sqoop/schema/type/TestArray.java b/common/src/test/java/org/apache/sqoop/schema/type/TestArray.java index 82a7d8e7..49a8ab1d 100644 --- a/common/src/test/java/org/apache/sqoop/schema/type/TestArray.java +++ b/common/src/test/java/org/apache/sqoop/schema/type/TestArray.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.schema.type; -import static org.junit.Assert.*; +import static org.testng.Assert.*; -import org.junit.Test; +import org.testng.annotations.Test; public class TestArray { diff --git a/common/src/test/java/org/apache/sqoop/schema/type/TestEnum.java b/common/src/test/java/org/apache/sqoop/schema/type/TestEnum.java index f97ebf43..6266e362 100644 --- a/common/src/test/java/org/apache/sqoop/schema/type/TestEnum.java +++ b/common/src/test/java/org/apache/sqoop/schema/type/TestEnum.java @@ -17,13 +17,13 @@ */ package org.apache.sqoop.schema.type; -import static org.junit.Assert.*; +import static org.testng.Assert.*; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; -import org.junit.Test; +import org.testng.annotations.Test; public class TestEnum { diff --git a/common/src/test/java/org/apache/sqoop/schema/type/TestMap.java b/common/src/test/java/org/apache/sqoop/schema/type/TestMap.java index 1f3abfb1..962fa560 100644 --- a/common/src/test/java/org/apache/sqoop/schema/type/TestMap.java +++ b/common/src/test/java/org/apache/sqoop/schema/type/TestMap.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.schema.type; -import static org.junit.Assert.*; +import static org.testng.Assert.*; -import org.junit.Test; +import org.testng.annotations.Test; public class TestMap { diff --git a/common/src/test/java/org/apache/sqoop/schema/type/TestSet.java b/common/src/test/java/org/apache/sqoop/schema/type/TestSet.java index daca037c..bf236555 100644 --- a/common/src/test/java/org/apache/sqoop/schema/type/TestSet.java +++ b/common/src/test/java/org/apache/sqoop/schema/type/TestSet.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.schema.type; -import static org.junit.Assert.*; +import static org.testng.Assert.*; -import org.junit.Test; +import org.testng.annotations.Test; public class TestSet { 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 948c0a61..131f1a3a 100644 --- a/common/src/test/java/org/apache/sqoop/submission/TestSubmissionStatus.java +++ b/common/src/test/java/org/apache/sqoop/submission/TestSubmissionStatus.java @@ -17,13 +17,13 @@ */ package org.apache.sqoop.submission; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; import java.util.List; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; /** * Test class for org.apache.sqoop.submission.SubmissionStatus 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 0cf5d2b9..fed943c6 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 @@ -17,8 +17,8 @@ */ package org.apache.sqoop.submission.counter; -import org.junit.Assert; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.Test; /** * Test class for org.apache.sqoop.submission.counter.Counter 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 ae7aaf01..0fd73987 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 @@ -17,9 +17,9 @@ */ package org.apache.sqoop.submission.counter; -import org.junit.Assert; +import org.testng.Assert; -import org.junit.Test; +import org.testng.annotations.Test; /** * Test class for org.apache.sqoop.submission.counter.CounterGroup 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 90a35c30..4d0a2d9a 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 @@ -17,9 +17,9 @@ */ package org.apache.sqoop.submission.counter; -import org.junit.Test; +import org.testng.annotations.Test; -import org.junit.Assert; +import org.testng.Assert; /** * Test Class for org.apache.sqoop.submission.counter.TestCounters diff --git a/common/src/test/java/org/apache/sqoop/utils/TestClassUtils.java b/common/src/test/java/org/apache/sqoop/utils/TestClassUtils.java index 53ece870..161a1fa0 100644 --- a/common/src/test/java/org/apache/sqoop/utils/TestClassUtils.java +++ b/common/src/test/java/org/apache/sqoop/utils/TestClassUtils.java @@ -17,12 +17,12 @@ */ package org.apache.sqoop.utils; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.testng.AssertJUnit.assertArrayEquals; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; /** * 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 1edc4047..59956671 100644 --- a/common/src/test/java/org/apache/sqoop/utils/TestMapResourceBundle.java +++ b/common/src/test/java/org/apache/sqoop/utils/TestMapResourceBundle.java @@ -17,12 +17,12 @@ */ package org.apache.sqoop.utils; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.*; +import static org.testng.Assert.*; /** * 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 813969e7..2fd11aac 100644 --- a/common/src/test/java/org/apache/sqoop/validation/TestStatus.java +++ b/common/src/test/java/org/apache/sqoop/validation/TestStatus.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.validation; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.*; /** * diff --git a/common/src/test/java/org/apache/sqoop/validation/TestValidationRunner.java b/common/src/test/java/org/apache/sqoop/validation/TestValidationRunner.java index 68254352..e2d4299a 100644 --- a/common/src/test/java/org/apache/sqoop/validation/TestValidationRunner.java +++ b/common/src/test/java/org/apache/sqoop/validation/TestValidationRunner.java @@ -26,10 +26,10 @@ import org.apache.sqoop.validation.validators.NotEmpty; import org.apache.sqoop.validation.validators.NotNull; import org.apache.sqoop.validation.validators.AbstractValidator; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertTrue; /** */ diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestCSVURIValidator.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestCSVURIValidator.java index dfb6fdda..ecbe08c5 100644 --- a/common/src/test/java/org/apache/sqoop/validation/validators/TestCSVURIValidator.java +++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestCSVURIValidator.java @@ -18,9 +18,9 @@ package org.apache.sqoop.validation.validators; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** */ diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java index cdfa2a9a..3b6e2fea 100644 --- a/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java +++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java @@ -17,13 +17,13 @@ */ package org.apache.sqoop.validation.validators; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import java.util.List; import org.apache.sqoop.validation.Message; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; public class TestClassAvailable { diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestContains.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestContains.java index 485efddd..3b5add5f 100644 --- a/common/src/test/java/org/apache/sqoop/validation/validators/TestContains.java +++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestContains.java @@ -18,9 +18,9 @@ package org.apache.sqoop.validation.validators; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** */ diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestHostAndPortValidator.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestHostAndPortValidator.java index 4ca3048b..401d60c6 100644 --- a/common/src/test/java/org/apache/sqoop/validation/validators/TestHostAndPortValidator.java +++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestHostAndPortValidator.java @@ -18,16 +18,16 @@ package org.apache.sqoop.validation.validators; import org.apache.sqoop.validation.Status; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; public class TestHostAndPortValidator { AbstractValidator validator = new HostAndPortValidator(); - @Before + @BeforeMethod public void setUp() { validator.reset(); assertEquals(0, validator.getMessages().size()); diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestNotEmpty.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestNotEmpty.java index 1e53e0fa..70184485 100644 --- a/common/src/test/java/org/apache/sqoop/validation/validators/TestNotEmpty.java +++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestNotEmpty.java @@ -19,11 +19,11 @@ import org.apache.sqoop.validation.Message; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** */ diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestNotNull.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestNotNull.java index 0a0b5dcb..ee81e09a 100644 --- a/common/src/test/java/org/apache/sqoop/validation/validators/TestNotNull.java +++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestNotNull.java @@ -19,11 +19,11 @@ import org.apache.sqoop.validation.Message; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** */ diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestNullOrContains.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestNullOrContains.java index 60eafff5..a23b5047 100644 --- a/common/src/test/java/org/apache/sqoop/validation/validators/TestNullOrContains.java +++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestNullOrContains.java @@ -18,9 +18,9 @@ package org.apache.sqoop.validation.validators; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** */ diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestStartsWith.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestStartsWith.java index 0fd464c7..89b9671c 100644 --- a/common/src/test/java/org/apache/sqoop/validation/validators/TestStartsWith.java +++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestStartsWith.java @@ -18,9 +18,9 @@ package org.apache.sqoop.validation.validators; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** */ diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestValidator.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestValidator.java index 49b76094..9b92480d 100644 --- a/common/src/test/java/org/apache/sqoop/validation/validators/TestValidator.java +++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestValidator.java @@ -19,9 +19,9 @@ import org.apache.sqoop.validation.Message; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** * diff --git a/connector/connector-generic-jdbc/pom.xml b/connector/connector-generic-jdbc/pom.xml index a96b348e..7bdeddb9 100644 --- a/connector/connector-generic-jdbc/pom.xml +++ b/connector/connector-generic-jdbc/pom.xml @@ -49,8 +49,8 @@ limitations under the License. - junit - junit + org.testng + testng test diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcExecutorTest.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcExecutorTest.java index 61846b7b..1734a162 100644 --- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcExecutorTest.java +++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcExecutorTest.java @@ -17,10 +17,10 @@ */ package org.apache.sqoop.connector.jdbc; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; public class GenericJdbcExecutorTest { private final String table; @@ -37,7 +37,7 @@ public GenericJdbcExecutorTest() { GenericJdbcTestConstants.URL, null, null); } - @Before + @BeforeMethod public void setUp() { if(executor.existTable(emptyTable)) { executor.executeUpdate("DROP TABLE " + emptyTable); diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExtractor.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExtractor.java index 8e1ce5b7..3014ed87 100644 --- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExtractor.java +++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExtractor.java @@ -17,7 +17,6 @@ */ package org.apache.sqoop.connector.jdbc; - import org.apache.sqoop.common.MutableContext; import org.apache.sqoop.common.MutableMapContext; import org.apache.sqoop.common.SqoopException; @@ -32,12 +31,12 @@ import org.apache.sqoop.schema.type.FixedPoint; import org.apache.sqoop.schema.type.Text; import org.joda.time.LocalDate; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.fail; public class TestExtractor { @@ -55,7 +54,7 @@ public TestExtractor() { tableName = getClass().getSimpleName().toUpperCase(); } - @Before + @BeforeMethod public void setUp() { executor = new GenericJdbcExecutor(GenericJdbcTestConstants.DRIVER, GenericJdbcTestConstants.URL, null, null); @@ -74,7 +73,7 @@ public void setUp() { } } - @After + @AfterMethod public void tearDown() { executor.close(); } @@ -159,7 +158,7 @@ public void testSubquery() throws Exception { } @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testIncorrectSchemaColumnSize() throws Exception { MutableContext context = new MutableMapContext(); diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestFromInitializer.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestFromInitializer.java index 345fe9ba..e8c0f0b8 100644 --- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestFromInitializer.java +++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestFromInitializer.java @@ -30,11 +30,11 @@ import org.apache.sqoop.schema.type.FixedPoint; import org.apache.sqoop.schema.type.FloatingPoint; import org.apache.sqoop.schema.type.Text; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; public class TestFromInitializer { @@ -59,7 +59,7 @@ public TestFromInitializer() { tableColumns = "ICOL,VCOL"; } - @Before + @BeforeMethod public void setUp() { executor = new GenericJdbcExecutor(GenericJdbcTestConstants.DRIVER, GenericJdbcTestConstants.URL, null, null); @@ -108,7 +108,7 @@ public Schema getSchema(String name) { ; } - @After + @AfterMethod public void tearDown() { executor.close(); } diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestGenericJdbcConnectorUpgrader.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestGenericJdbcConnectorUpgrader.java index d6fe504c..febb90fc 100644 --- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestGenericJdbcConnectorUpgrader.java +++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestGenericJdbcConnectorUpgrader.java @@ -28,12 +28,12 @@ import org.apache.sqoop.model.MLinkConfig; import org.apache.sqoop.model.MStringInput; import org.apache.sqoop.model.MToConfig; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.util.LinkedList; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** * Test upgrader. @@ -42,7 +42,7 @@ public class TestGenericJdbcConnectorUpgrader { private GenericJdbcConnectorUpgrader upgrader; - @Before + @BeforeMethod public void setUp() { upgrader = new GenericJdbcConnectorUpgrader(); } diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestLoader.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestLoader.java index 538b0336..d299f1df 100644 --- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestLoader.java +++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestLoader.java @@ -18,8 +18,6 @@ package org.apache.sqoop.connector.jdbc; import java.sql.ResultSet; -import java.util.Arrays; -import java.util.Collection; import org.apache.sqoop.common.MutableContext; import org.apache.sqoop.common.MutableMapContext; @@ -28,17 +26,15 @@ import org.apache.sqoop.etl.io.DataReader; import org.apache.sqoop.job.etl.Loader; import org.apache.sqoop.job.etl.LoaderContext; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.fail; -@RunWith(Parameterized.class) public class TestLoader { private final String tableName; @@ -49,17 +45,18 @@ public class TestLoader { private int numberOfRows; - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] {{50}, {100}, {101}, {150}, {200}}); + @DataProvider(name="test-jdbc-loader") + public static Object[][] data() { + return new Object[][] {{50}, {100}, {101}, {150}, {200}}; } + @Factory(dataProvider="test-jdbc-loader") public TestLoader(int numberOfRows) { this.numberOfRows = numberOfRows; - tableName = getClass().getSimpleName().toUpperCase(); + this.tableName = getClass().getSimpleName().toUpperCase(); } - @Before + @BeforeMethod public void setUp() { executor = new GenericJdbcExecutor(GenericJdbcTestConstants.DRIVER, GenericJdbcTestConstants.URL, null, null); @@ -73,7 +70,7 @@ public void setUp() { } } - @After + @AfterMethod public void tearDown() { executor.close(); } diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestPartitioner.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestPartitioner.java index d62e4941..e0bbf3f9 100644 --- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestPartitioner.java +++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestPartitioner.java @@ -32,10 +32,10 @@ import org.apache.sqoop.job.etl.Partition; import org.apache.sqoop.job.etl.Partitioner; import org.apache.sqoop.job.etl.PartitionerContext; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertTrue; public class TestPartitioner { diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestToInitializer.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestToInitializer.java index 2d7ec3a1..01dfab31 100644 --- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestToInitializer.java +++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestToInitializer.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.connector.jdbc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import org.apache.sqoop.common.MutableContext; import org.apache.sqoop.common.MutableMapContext; @@ -31,9 +31,9 @@ import org.apache.sqoop.validation.ConfigValidationResult; import org.apache.sqoop.validation.ConfigValidationRunner; import org.apache.sqoop.validation.Status; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; public class TestToInitializer { private final String schemaName; @@ -57,7 +57,7 @@ public TestToInitializer() { tableColumns = "ICOL,VCOL"; } - @Before + @BeforeMethod public void setUp() { executor = new GenericJdbcExecutor(GenericJdbcTestConstants.DRIVER, GenericJdbcTestConstants.URL, null, null); @@ -74,7 +74,7 @@ public void setUp() { } } - @After + @AfterMethod public void tearDown() { executor.close(); } diff --git a/connector/connector-hdfs/pom.xml b/connector/connector-hdfs/pom.xml index b06275a2..dff6f5f2 100644 --- a/connector/connector-hdfs/pom.xml +++ b/connector/connector-hdfs/pom.xml @@ -33,8 +33,8 @@ limitations under the License. - junit - junit + org.testng + testng diff --git a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestExtractor.java b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestExtractor.java index e5b7b2a8..d761b6d1 100644 --- a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestExtractor.java +++ b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestExtractor.java @@ -19,6 +19,7 @@ import static org.apache.sqoop.connector.hdfs.configuration.ToFormat.SEQUENCE_FILE; import static org.apache.sqoop.connector.hdfs.configuration.ToFormat.TEXT_FILE; +import static org.testng.AssertJUnit.assertTrue; import java.io.IOException; import java.util.ArrayList; @@ -36,14 +37,13 @@ import org.apache.sqoop.etl.io.DataWriter; import org.apache.sqoop.job.etl.Extractor; import org.apache.sqoop.job.etl.ExtractorContext; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.testng.annotations.AfterMethod; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; -@RunWith(Parameterized.class) public class TestExtractor extends TestHdfsBase { private static final String INPUT_ROOT = System.getProperty("maven.build.directory", "/tmp") + "/sqoop/warehouse/"; private static final int NUMBER_OF_FILES = 5; @@ -54,6 +54,7 @@ public class TestExtractor extends TestHdfsBase { private final String inputDirectory; private Extractor extractor; + @Factory(dataProvider="test-hdfs-extractor") public TestExtractor(ToFormat outputFileType, Class compressionClass) throws Exception { @@ -63,18 +64,18 @@ public TestExtractor(ToFormat outputFileType, this.extractor = new HdfsExtractor(); } - @Parameterized.Parameters - public static Collection data() { + @DataProvider(name="test-hdfs-extractor") + public static Object[][] data() { List parameters = new ArrayList(); for (Class compressionClass : new Class[]{null, DefaultCodec.class, BZip2Codec.class}) { for (Object outputFileType : new Object[]{TEXT_FILE, SEQUENCE_FILE}) { parameters.add(new Object[]{outputFileType, compressionClass}); } } - return parameters; + return parameters.toArray(new Object[0][]); } - @Before + @BeforeMethod public void setUp() throws Exception { FileUtils.mkdirs(inputDirectory); switch (this.outputFileType) { @@ -88,7 +89,7 @@ public void setUp() throws Exception { } } - @After + @AfterMethod public void tearDown() throws IOException { FileUtils.delete(inputDirectory); } @@ -140,7 +141,7 @@ public void writeRecord(Object obj) { extractor.extract(context, emptyLinkConfig, emptyJobConfig, partition); for (int index = 0; index < NUMBER_OF_FILES * NUMBER_OF_ROWS_PER_FILE; ++index) { - Assert.assertTrue("Index " + (index + 1) + " was not visited", visited[index]); + assertTrue("Index " + (index + 1) + " was not visited", visited[index]); } } @@ -193,7 +194,7 @@ public void writeRecord(Object obj) { extractor.extract(context, emptyLinkConfig, fromJobConfiguration, partition); for (int index = 0; index < NUMBER_OF_FILES * NUMBER_OF_ROWS_PER_FILE; ++index) { - Assert.assertTrue("Index " + (index + 1) + " was not visited", visited[index]); + assertTrue("Index " + (index + 1) + " was not visited", visited[index]); } } } diff --git a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestHdfsUtils.java b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestHdfsUtils.java index bba65029..8eefe058 100644 --- a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestHdfsUtils.java +++ b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestHdfsUtils.java @@ -21,9 +21,13 @@ import org.apache.sqoop.connector.hdfs.configuration.FromJobConfiguration; import org.apache.sqoop.connector.hdfs.configuration.LinkConfiguration; import org.apache.sqoop.connector.hdfs.configuration.ToJobConfiguration; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.*; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; public class TestHdfsUtils { diff --git a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestLinkConfig.java b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestLinkConfig.java index 176d0dfe..27a94c67 100644 --- a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestLinkConfig.java +++ b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestLinkConfig.java @@ -18,10 +18,10 @@ package org.apache.sqoop.connector.hdfs; import org.apache.sqoop.connector.hdfs.configuration.LinkConfig; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertTrue; public class TestLinkConfig { @Test diff --git a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestLoader.java b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestLoader.java index be57fa0c..506dc823 100644 --- a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestLoader.java +++ b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestLoader.java @@ -44,14 +44,13 @@ import org.apache.sqoop.etl.io.DataReader; import org.apache.sqoop.job.etl.Loader; import org.apache.sqoop.job.etl.LoaderContext; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.testng.annotations.AfterMethod; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; -@RunWith(Parameterized.class) public class TestLoader extends TestHdfsBase { private static final String INPUT_ROOT = System.getProperty("maven.build.directory", "/tmp") + "/sqoop/warehouse/"; private static final int NUMBER_OF_ROWS_PER_FILE = 1000; @@ -61,6 +60,7 @@ public class TestLoader extends TestHdfsBase { private final String outputDirectory; private Loader loader; + @Factory(dataProvider="test-hdfs-loader") public TestLoader(ToFormat outputFormat, ToCompression compression) throws Exception { @@ -70,8 +70,8 @@ public TestLoader(ToFormat outputFormat, this.loader = new HdfsLoader(); } - @Parameterized.Parameters - public static Collection data() { + @DataProvider(name="test-hdfs-loader") + public static Object[][] data() { List parameters = new ArrayList(); for (ToCompression compression : new ToCompression[]{ ToCompression.DEFAULT, @@ -82,13 +82,13 @@ public static Collection data() { parameters.add(new Object[]{outputFileType, compression}); } } - return parameters; + return parameters.toArray(new Object[0][]); } - @Before + @BeforeMethod public void setUp() throws Exception {} - @After + @AfterMethod public void tearDown() throws IOException { FileUtils.delete(outputDirectory); } diff --git a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestPartitioner.java b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestPartitioner.java index 04e09cd1..952932cd 100644 --- a/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestPartitioner.java +++ b/connector/connector-hdfs/src/test/java/org/apache/sqoop/connector/hdfs/TestPartitioner.java @@ -19,11 +19,10 @@ import static org.apache.sqoop.connector.hdfs.configuration.ToFormat.SEQUENCE_FILE; import static org.apache.sqoop.connector.hdfs.configuration.ToFormat.TEXT_FILE; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import org.apache.hadoop.conf.Configuration; @@ -37,13 +36,12 @@ import org.apache.sqoop.job.etl.Partition; import org.apache.sqoop.job.etl.Partitioner; import org.apache.sqoop.job.etl.PartitionerContext; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; -@RunWith(Parameterized.class) public class TestPartitioner extends TestHdfsBase { private static final String INPUT_ROOT = System.getProperty("maven.build.directory", "/tmp") + "/sqoop/warehouse/"; private static final int NUMBER_OF_FILES = 5; @@ -55,13 +53,14 @@ public class TestPartitioner extends TestHdfsBase { private final String inputDirectory; + @Factory(dataProvider="test-hdfs-partitioner") public TestPartitioner(ToFormat outputFileType, Class compressionClass) { this.inputDirectory = INPUT_ROOT + getClass().getSimpleName(); this.outputFileType = outputFileType; this.compressionClass = compressionClass; } - @Before + @BeforeMethod public void setUp() throws Exception { partitioner = new HdfsPartitioner(); FileUtils.mkdirs(inputDirectory); @@ -77,20 +76,20 @@ public void setUp() throws Exception { } } - @After + @AfterMethod public void tearDown() throws IOException { FileUtils.delete(inputDirectory); } - @Parameterized.Parameters - public static Collection data() { + @DataProvider(name="test-hdfs-partitioner") + public static Object[][] data() { List parameters = new ArrayList(); for (Class compressionClass : new Class[]{null, DefaultCodec.class, BZip2Codec.class}) { for (Object outputFileType : new Object[]{TEXT_FILE, SEQUENCE_FILE}) { parameters.add(new Object[]{outputFileType, compressionClass}); } } - return parameters; + return parameters.toArray(new Object[0][]); } @Test diff --git a/connector/connector-kafka/pom.xml b/connector/connector-kafka/pom.xml index 82e43b3c..e0f06846 100644 --- a/connector/connector-kafka/pom.xml +++ b/connector/connector-kafka/pom.xml @@ -42,6 +42,12 @@ limitations under the License. org.apache.sqoop sqoop-common-test + + + org.testng + testng + test + \ No newline at end of file diff --git a/connector/connector-kafka/src/main/java/org/apache/sqoop/connector/kafka/KafkaToDestroyer.java b/connector/connector-kafka/src/main/java/org/apache/sqoop/connector/kafka/KafkaToDestroyer.java index c522d917..e024d56c 100644 --- a/connector/connector-kafka/src/main/java/org/apache/sqoop/connector/kafka/KafkaToDestroyer.java +++ b/connector/connector-kafka/src/main/java/org/apache/sqoop/connector/kafka/KafkaToDestroyer.java @@ -23,7 +23,7 @@ import org.apache.sqoop.job.etl.Destroyer; import org.apache.sqoop.job.etl.DestroyerContext; -public class KafkaToDestroyer extends Destroyer { +public class KafkaToDestroyer extends Destroyer { private static final Logger LOG = Logger.getLogger(KafkaToDestroyer.class); diff --git a/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestConfiguration.java b/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestConfiguration.java index 0aca80d8..ecdbdcac 100644 --- a/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestConfiguration.java +++ b/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestConfiguration.java @@ -21,9 +21,9 @@ import org.apache.sqoop.validation.ConfigValidationResult; import org.apache.sqoop.validation.ConfigValidationRunner; import org.apache.sqoop.validation.Status; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; public class TestConfiguration { @Test diff --git a/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestKafkaLoader.java b/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestKafkaLoader.java index 4ed027fa..f060c357 100644 --- a/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestKafkaLoader.java +++ b/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestKafkaLoader.java @@ -18,23 +18,21 @@ package org.apache.sqoop.connector.kafka; import kafka.message.MessageAndMetadata; -import org.apache.sqoop.common.test.categories.SlowTests; import org.apache.sqoop.connector.kafka.configuration.ToJobConfiguration; import org.apache.sqoop.connector.kafka.configuration.LinkConfiguration; import org.apache.sqoop.common.test.kafka.TestUtil; import org.apache.sqoop.etl.io.DataReader; import org.apache.sqoop.job.etl.LoaderContext; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.testng.annotations.AfterClass; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.io.IOException; import java.util.ArrayList; import java.util.List; -@Category({ SlowTests.class }) +@Test(groups="slow") public class TestKafkaLoader { private static TestUtil testUtil = TestUtil.getInstance(); diff --git a/connector/connector-kite/pom.xml b/connector/connector-kite/pom.xml index 17821f93..11ec534f 100644 --- a/connector/connector-kite/pom.xml +++ b/connector/connector-kite/pom.xml @@ -44,8 +44,8 @@ limitations under the License. - junit - junit + org.testng + testng test @@ -55,7 +55,7 @@ limitations under the License. org.powermock - powermock-module-junit4 + powermock-module-testng test diff --git a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteExecutor.java b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteExecutor.java index 43736ccb..3e7d1f11 100644 --- a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteExecutor.java +++ b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteExecutor.java @@ -20,24 +20,24 @@ import org.apache.avro.Schema; import org.apache.avro.generic.GenericRecord; import org.apache.avro.generic.GenericRecordBuilder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; import org.kitesdk.data.Dataset; import org.kitesdk.data.DatasetDescriptor; import org.kitesdk.data.DatasetReader; import org.kitesdk.data.DatasetWriter; +import org.testng.AssertJUnit; +import org.testng.IObjectFactory; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.ObjectFactory; +import org.testng.annotations.Test; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; -import static junit.framework.TestCase.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; +import static org.testng.AssertJUnit.assertTrue; public class TestKiteExecutor { @@ -55,7 +55,12 @@ public class TestKiteExecutor { private KiteDatasetExecutor executor; - @Before + @ObjectFactory + public IObjectFactory getObjectFactory() { + return new org.powermock.modules.testng.PowerMockObjectFactory(); + } + + @BeforeMethod public void setUp() { initMocks(this); when(datasetMock.newWriter()).thenReturn(writerMock); @@ -68,7 +73,7 @@ public void setUp() { executor = new KiteDatasetExecutor(datasetMock); } - @After + @AfterMethod public void tearDown() { executor.closeWriter(); executor.closeReader(); @@ -117,14 +122,14 @@ public void testReaderRecord() { // exercise & verify for (int i = 0; i < NUMBER_OF_ROWS; i++) { Object[] actual = executor.readRecord(); - assertNotNull(actual); - assertEquals(2, actual.length); - assertEquals(1, actual[0]); - assertEquals("foo", actual[1]); + AssertJUnit.assertNotNull(actual); + AssertJUnit.assertEquals(2, actual.length); + AssertJUnit.assertEquals(1, actual[0]); + AssertJUnit.assertEquals("foo", actual[1]); } when(readerMock.hasNext()).thenReturn(false); Object[] actual = executor.readRecord(); - assertNull(actual); + AssertJUnit.assertNull(actual); } @Test diff --git a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteExtractor.java b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteExtractor.java index 0e2c8652..d2c22499 100644 --- a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteExtractor.java +++ b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteExtractor.java @@ -24,9 +24,9 @@ import org.apache.sqoop.job.etl.ExtractorContext; import org.apache.sqoop.schema.Schema; import org.apache.sqoop.schema.type.Text; -import org.junit.Before; -import org.junit.Test; import org.mockito.stubbing.OngoingStubbing; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import static org.mockito.Matchers.any; import static org.mockito.Mockito.times; @@ -56,7 +56,7 @@ public void writeRecord(Object obj) { } }; - @Before + @BeforeMethod public void setUp() { initMocks(this); diff --git a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteFromInitializer.java b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteFromInitializer.java index 557a3c25..027056ff 100644 --- a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteFromInitializer.java +++ b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteFromInitializer.java @@ -20,24 +20,24 @@ import org.apache.sqoop.common.SqoopException; import org.apache.sqoop.connector.kite.configuration.FromJobConfiguration; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; import org.kitesdk.data.Datasets; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.testng.PowerMockTestCase; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.mockito.PowerMockito.mockStatic; -@RunWith(PowerMockRunner.class) @PrepareForTest(Datasets.class) -public class TestKiteFromInitializer { +@PowerMockIgnore("org.apache.sqoop.common.ErrorCode") +public class TestKiteFromInitializer extends PowerMockTestCase { private KiteFromInitializer initializer; - @Before + @BeforeMethod public void setUp() { initMocks(this); mockStatic(Datasets.class); @@ -56,7 +56,7 @@ public void testInitializePassed() { initializer.initialize(null, null, jobConfig); } - @Test(expected=SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testInitializeFailed() { // setup FromJobConfiguration jobConfig = new FromJobConfiguration(); diff --git a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteLoader.java b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteLoader.java index d302aefd..8f3a5f80 100644 --- a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteLoader.java +++ b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteLoader.java @@ -25,8 +25,8 @@ import org.apache.sqoop.job.etl.LoaderContext; import org.apache.sqoop.schema.Schema; import org.apache.sqoop.schema.type.Text; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import static org.mockito.Mockito.any; import static org.mockito.Mockito.times; @@ -40,7 +40,7 @@ public class TestKiteLoader { @org.mockito.Mock private KiteDatasetExecutor executorMock; - @Before + @BeforeMethod public void setUp() { initMocks(this); diff --git a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteToDestroyer.java b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteToDestroyer.java index 92424c47..8c61e759 100644 --- a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteToDestroyer.java +++ b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteToDestroyer.java @@ -23,12 +23,12 @@ import org.apache.sqoop.connector.kite.configuration.ToJobConfiguration; import org.apache.sqoop.job.etl.DestroyerContext; import org.apache.sqoop.schema.Schema; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; import org.kitesdk.data.Datasets; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.modules.testng.PowerMockTestCase; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -37,9 +37,9 @@ import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.verifyStatic; -@RunWith(PowerMockRunner.class) @PrepareForTest({KiteDatasetExecutor.class, Datasets.class}) -public class TestKiteToDestroyer { +@PowerMockIgnore("org.apache.sqoop.common.ErrorCode") +public class TestKiteToDestroyer extends PowerMockTestCase { private KiteToDestroyer destroyer; @@ -52,7 +52,7 @@ public class TestKiteToDestroyer { @org.mockito.Mock private KiteDatasetExecutor executorMock; - @Before + @BeforeMethod public void setUp() { initMocks(this); mockStatic(KiteDatasetExecutor.class); diff --git a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteToInitializer.java b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteToInitializer.java index 50c30641..93efa93c 100644 --- a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteToInitializer.java +++ b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/TestKiteToInitializer.java @@ -22,26 +22,26 @@ import org.apache.sqoop.connector.kite.configuration.LinkConfiguration; import org.apache.sqoop.connector.kite.configuration.ToJobConfiguration; import org.apache.sqoop.schema.Schema; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; import org.kitesdk.data.Datasets; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.modules.testng.PowerMockTestCase; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.mockito.PowerMockito.mockStatic; -@RunWith(PowerMockRunner.class) @PrepareForTest(Datasets.class) -public class TestKiteToInitializer { +@PowerMockIgnore("org.apache.sqoop.common.ErrorCode") +public class TestKiteToInitializer extends PowerMockTestCase { private KiteToInitializer initializer; - @Before + @BeforeMethod public void setUp() { initMocks(this); mockStatic(Datasets.class); @@ -62,7 +62,7 @@ public void testInitializePassed() { initializer.initialize(null, linkConfig, toJobConfig); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testInitializeFailed() { // setup LinkConfiguration linkConfig = new LinkConfiguration(); @@ -85,4 +85,4 @@ public void testGetSchema() { assertTrue(schema.isEmpty()); } -} \ No newline at end of file +} diff --git a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/configuration/TestConfigUtil.java b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/configuration/TestConfigUtil.java index c56ef026..827024bd 100644 --- a/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/configuration/TestConfigUtil.java +++ b/connector/connector-kite/src/test/java/org/apache/sqoop/connector/kite/configuration/TestConfigUtil.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.connector.kite.configuration; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** * Test configuration objects. diff --git a/connector/connector-sdk/pom.xml b/connector/connector-sdk/pom.xml index 27950848..ff79ec17 100644 --- a/connector/connector-sdk/pom.xml +++ b/connector/connector-sdk/pom.xml @@ -41,8 +41,8 @@ limitations under the License. commons-codec - junit - junit + org.testng + testng test diff --git a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/common/TestSqoopIDFUtils.java b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/common/TestSqoopIDFUtils.java index 68890ccb..71db8dae 100644 --- a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/common/TestSqoopIDFUtils.java +++ b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/common/TestSqoopIDFUtils.java @@ -17,13 +17,13 @@ */ package org.apache.sqoop.connector.common; -import static org.junit.Assert.*; +import static org.testng.Assert.*; import static org.apache.sqoop.connector.common.SqoopIDFUtils.*; import org.apache.sqoop.schema.type.AbstractComplexListType; import org.apache.sqoop.schema.type.Array; import org.apache.sqoop.schema.type.Text; -import org.junit.Test; +import org.testng.annotations.Test; import java.io.UnsupportedEncodingException; import java.util.ArrayList; diff --git a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestAVROIntermediateDataFormat.java b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestAVROIntermediateDataFormat.java index b00b3b98..816cc712 100644 --- a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestAVROIntermediateDataFormat.java +++ b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestAVROIntermediateDataFormat.java @@ -20,7 +20,7 @@ import static org.apache.sqoop.connector.common.SqoopAvroUtils.createEnumSchema; import static org.apache.sqoop.connector.common.TestSqoopIDFUtils.getByteFieldString; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import org.apache.avro.generic.GenericData; import org.apache.avro.generic.GenericRecord; @@ -34,8 +34,8 @@ import org.apache.sqoop.schema.type.FixedPoint; import org.apache.sqoop.schema.type.Text; import org.joda.time.LocalDateTime; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -62,7 +62,7 @@ public class TestAVROIntermediateDataFormat { private final static org.joda.time.LocalTime time = new org.joda.time.LocalTime(12, 59, 59); private final static org.joda.time.LocalDate date = new org.joda.time.LocalDate(2014, 10, 01); - @Before + @BeforeMethod public void setUp() { createAvroIDF(); } diff --git a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestCSVIntermediateDataFormat.java b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestCSVIntermediateDataFormat.java index 64b18fd4..e116f3cc 100644 --- a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestCSVIntermediateDataFormat.java +++ b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestCSVIntermediateDataFormat.java @@ -18,10 +18,10 @@ */ package org.apache.sqoop.connector.idf; -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 static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; import static org.apache.sqoop.connector.common.SqoopIDFUtils.*; import static org.apache.sqoop.connector.common.TestSqoopIDFUtils.getByteFieldString; @@ -46,14 +46,14 @@ import org.apache.sqoop.schema.type.Text; import org.apache.sqoop.schema.type.Time; import org.joda.time.DateTimeZone; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; public class TestCSVIntermediateDataFormat { private CSVIntermediateDataFormat dataFormat; - @Before + @BeforeMethod public void setUp() { dataFormat = new CSVIntermediateDataFormat(); } @@ -76,7 +76,7 @@ public void testNullInputAsCSVTextInObjectArrayOut() { assertNull(out); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testEmptyInputAsCSVTextInObjectArrayOut() { Schema schema = new Schema("test"); schema.addColumn(new FixedPoint("1")).addColumn(new FixedPoint("2")).addColumn(new Text("3")).addColumn(new Text("4")) @@ -508,7 +508,7 @@ public void testDateTimeWithFractionNoTimezoneWithCSVTextInObjectArrayOut() { } // since date is not quoted - @Test(expected = Exception.class) + @Test(expectedExceptions = Exception.class) public void testDateTimeNoQuotesWithFractionTimezoneWithCSVTextInObjectArrayOut() { Schema schema = new Schema("test"); schema.addColumn(new DateTime("1", true, true)); @@ -520,7 +520,7 @@ public void testDateTimeNoQuotesWithFractionTimezoneWithCSVTextInObjectArrayOut( } // since date is not in expected format - @Test(expected = Exception.class) + @Test(expectedExceptions = Exception.class) public void testDateTimeIncorrectFormatWithCSVTextInObjectArrayOut() { Schema schema = new Schema("test"); schema.addColumn(new DateTime("1", true, true)); @@ -636,7 +636,7 @@ public void testBitWithObjectArrayInAndCSVTextOut() { assertEquals("true,false", dataFormat.getCSVTextData()); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testUnsupportedBitWithObjectArrayInAndCSVTextOut() { Schema schema = new Schema("test"); schema.addColumn(new Bit("1")).addColumn(new Bit("2")); @@ -682,7 +682,7 @@ public void testBitWithCSVTextInAndObjectArrayOut() { } } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testUnsupportedBitWithObjectArrayInAndObjectOut() { Schema schema = new Schema("test"); schema.addColumn(new Bit("1")).addColumn(new Bit("2")); @@ -695,7 +695,7 @@ public void testUnsupportedBitWithObjectArrayInAndObjectOut() { assertEquals(false, dataFormat.getObjectData()[1]); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testUnsupportedBitWithCSVTextInAndObjectOut() { Schema schema = new Schema("test"); schema.addColumn(new Bit("1")).addColumn(new Bit("2")); @@ -1101,7 +1101,7 @@ public void testMapWithCSVTextInCSVTextOut() { assertEquals(testData, dataFormat.getCSVTextData()); } //**************test cases for schema******************* - @Test(expected=SqoopException.class) + @Test(expectedExceptions=SqoopException.class) public void testEmptySchema() { String testData = "10,34,'54','random data'," + getByteFieldString(new byte[] { (byte) -112, (byte) 54}) + ",'\\n'"; @@ -1113,14 +1113,14 @@ public void testEmptySchema() { Object[] out = dataFormat.getObjectData(); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testNullSchema() { dataFormat.setSchema(null); @SuppressWarnings("unused") Object[] out = dataFormat.getObjectData(); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testNotSettingSchema() { @SuppressWarnings("unused") Object[] out = dataFormat.getObjectData(); diff --git a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestJSONIntermediateDataFormat.java b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestJSONIntermediateDataFormat.java index 86727129..44ea4fd9 100644 --- a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestJSONIntermediateDataFormat.java +++ b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestJSONIntermediateDataFormat.java @@ -19,7 +19,7 @@ package org.apache.sqoop.connector.idf; import static org.apache.sqoop.connector.common.TestSqoopIDFUtils.getByteFieldString; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import org.apache.sqoop.connector.common.SqoopIDFUtils; import org.apache.sqoop.schema.Schema; @@ -31,8 +31,8 @@ import org.joda.time.LocalDateTime; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.util.Arrays; import java.util.HashMap; @@ -48,7 +48,7 @@ public class TestJSONIntermediateDataFormat { private final static String dateTime = "'2014-10-01 12:00:00.000'"; private final static String time = "'12:59:59'"; - @Before + @BeforeMethod public void setUp() { createJSONIDF(); } diff --git a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/matcher/TestLocationMatcher.java b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/matcher/TestLocationMatcher.java index edf5fd92..624fa7b8 100644 --- a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/matcher/TestLocationMatcher.java +++ b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/matcher/TestLocationMatcher.java @@ -20,16 +20,16 @@ import org.apache.sqoop.common.SqoopException; import org.apache.sqoop.schema.NullSchema; import org.apache.sqoop.schema.Schema; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import static org.junit.Assert.assertArrayEquals; +import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; public class TestLocationMatcher { private LocationMatcher matcher; - @Before + @BeforeMethod public void setUp() { matcher = null; } @@ -95,7 +95,7 @@ public void testConvertWhenToSchemaIsLongerThanFromSchema() { * If TO schema has more fields than FROM schema, and NOT all of the extra * fields are "nullable", a SqoopException is expected. */ - @Test (expected = SqoopException.class) + @Test (expectedExceptions = SqoopException.class) public void testConvertWhenToSchemaIsLongerThanFromSchemaFail() { Schema from = SchemaFixture.createSchema("from", 2); Schema to = SchemaFixture.createSchema("to", 4); diff --git a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/matcher/TestNameMatcher.java b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/matcher/TestNameMatcher.java index 8d5d720e..76ff0da4 100644 --- a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/matcher/TestNameMatcher.java +++ b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/matcher/TestNameMatcher.java @@ -20,16 +20,16 @@ import org.apache.sqoop.common.SqoopException; import org.apache.sqoop.schema.NullSchema; import org.apache.sqoop.schema.Schema; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import static org.junit.Assert.assertArrayEquals; +import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; public class TestNameMatcher { private NameMatcher matcher; - @Before + @BeforeMethod public void setUp() { matcher = null; } @@ -99,7 +99,7 @@ public void testConvertWhenToSchemaIsLongerThanFromSchema() { * If TO schema has more fields than FROM schema, and NOT all of the extra * fields are "nullable", a SqoopException is expected. */ - @Test (expected = SqoopException.class) + @Test (expectedExceptions = SqoopException.class) public void testConvertWhenToSchemaIsLongerThanFromSchemaFail() { Schema from = SchemaFixture.createSchema("from", new String[]{"text1", "text2"}); diff --git a/core/pom.xml b/core/pom.xml index b6e9557b..0a8ec097 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -49,8 +49,8 @@ limitations under the License. - junit - junit + org.testng + testng test diff --git a/core/src/test/java/org/apache/sqoop/core/TestSqoopConfiguration.java b/core/src/test/java/org/apache/sqoop/core/TestSqoopConfiguration.java index 4d58bd13..e15691eb 100644 --- a/core/src/test/java/org/apache/sqoop/core/TestSqoopConfiguration.java +++ b/core/src/test/java/org/apache/sqoop/core/TestSqoopConfiguration.java @@ -20,13 +20,13 @@ import java.util.Properties; import org.apache.sqoop.common.SqoopException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; public class TestSqoopConfiguration { - @Before + @BeforeMethod public void setUp() throws Exception { // Unset any configuration dir if it is set by another test System.getProperties().remove(ConfigurationConstants.SYSPROP_CONFIG_DIR); diff --git a/core/src/test/java/org/apache/sqoop/driver/TestDriverConfigUpgrader.java b/core/src/test/java/org/apache/sqoop/driver/TestDriverConfigUpgrader.java index e5201fc0..ec548d5d 100644 --- a/core/src/test/java/org/apache/sqoop/driver/TestDriverConfigUpgrader.java +++ b/core/src/test/java/org/apache/sqoop/driver/TestDriverConfigUpgrader.java @@ -18,8 +18,8 @@ */ package org.apache.sqoop.driver; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNull; import java.util.LinkedList; import java.util.List; @@ -30,8 +30,8 @@ import org.apache.sqoop.model.MInput; import org.apache.sqoop.model.MIntegerInput; import org.apache.sqoop.model.MStringInput; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; /** */ @@ -39,7 +39,7 @@ public class TestDriverConfigUpgrader { DriverUpgrader upgrader; - @Before + @BeforeMethod public void initializeUpgrader() { upgrader = new DriverUpgrader(); } diff --git a/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java b/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java index 5bc1b036..926815d7 100644 --- a/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java +++ b/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -38,8 +38,8 @@ import org.apache.sqoop.repository.Repository; import org.apache.sqoop.repository.RepositoryManager; import org.apache.sqoop.request.HttpEventContext; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; public class TestJobManager { private JobManager jobManager; @@ -48,7 +48,7 @@ public class TestJobManager { private RepositoryManager repositoryManagerMock; private Repository jdbcRepoMock; - @Before + @BeforeMethod public void setUp() { jobManager = new JobManager(); connectorMgrMock = mock(ConnectorManager.class); diff --git a/core/src/test/java/org/apache/sqoop/driver/TestJobRequest.java b/core/src/test/java/org/apache/sqoop/driver/TestJobRequest.java index 3f360303..26560fe8 100644 --- a/core/src/test/java/org/apache/sqoop/driver/TestJobRequest.java +++ b/core/src/test/java/org/apache/sqoop/driver/TestJobRequest.java @@ -23,17 +23,17 @@ import org.apache.sqoop.driver.JobRequest; import org.apache.sqoop.utils.ClassUtils; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertTrue; public class TestJobRequest { private JobRequest jobRequest; - @Before + @BeforeMethod public void initializeSubmissionRequest() { jobRequest = new JobRequest(); } diff --git a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java index 56add070..f804a455 100644 --- a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java +++ b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.repository; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.anyString; @@ -62,8 +62,8 @@ import org.apache.sqoop.model.Validator; import org.apache.sqoop.validation.Status; import org.apache.sqoop.validation.validators.AbstractValidator; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import org.mockito.InOrder; public class TestJdbcRepository { @@ -76,7 +76,7 @@ public class TestJdbcRepository { private ConnectorConfigurableUpgrader connectorUpgraderMock; private DriverUpgrader driverUpgraderMock; - @Before + @BeforeMethod public void setUp() throws Exception { repoTransactionMock = mock(JdbcRepositoryTransaction.class); connectorMgrMock = mock(ConnectorManager.class); diff --git a/core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java b/core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java index 7cec5366..95b868a9 100644 --- a/core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java +++ b/core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java @@ -24,8 +24,8 @@ import org.apache.sqoop.core.PropertiesConfigurationProvider; import org.apache.sqoop.core.SqoopConfiguration; import org.apache.sqoop.core.TestUtils; -import org.junit.Assert; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.Test; public class TestRepositoryManager { diff --git a/docs/pom.xml b/docs/pom.xml index f8ccc344..7be68f0c 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -33,8 +33,8 @@ limitations under the License. - junit - junit + org.testng + testng test diff --git a/execution/mapreduce/pom.xml b/execution/mapreduce/pom.xml index ad7f489e..7b9eaa0c 100644 --- a/execution/mapreduce/pom.xml +++ b/execution/mapreduce/pom.xml @@ -35,8 +35,8 @@ limitations under the License. - junit - junit + org.testng + testng test diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java index cc0a3cc3..10ed33c1 100644 --- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java +++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java @@ -17,7 +17,7 @@ */ package org.apache.sqoop.job; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import java.io.DataInput; import java.io.DataOutput; @@ -54,8 +54,7 @@ import org.apache.sqoop.job.mr.SqoopNullOutputFormat; import org.apache.sqoop.job.mr.SqoopSplit; import org.apache.sqoop.job.util.MRJobTestUtil; -import org.junit.Assert; -import org.junit.Test; +import org.testng.annotations.Test; public class TestMapReduce { @@ -99,7 +98,7 @@ public void testSqoopMapper() throws Exception { SqoopInputFormat.class, SqoopMapper.class, DummyOutputFormat.class); - Assert.assertEquals("Job failed!", true, success); + assertEquals("Job failed!", true, success); } @Test @@ -121,7 +120,7 @@ public void testNullOutputFormat() throws Exception { SqoopInputFormat.class, SqoopMapper.class, SqoopNullOutputFormat.class); - Assert.assertEquals("Job failed!", true, success); + assertEquals("Job failed!", true, success); // Make sure both destroyers get called. assertEquals(1, DummyFromDestroyer.count); diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMatching.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMatching.java index 1b791e30..ab2178eb 100644 --- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMatching.java +++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMatching.java @@ -19,14 +19,14 @@ import static org.apache.sqoop.connector.common.SqoopIDFUtils.BYTE_FIELD_CHARSET; import static org.apache.sqoop.connector.common.SqoopIDFUtils.toText; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; -import java.util.Collection; import java.util.LinkedList; import java.util.List; @@ -58,13 +58,11 @@ import org.apache.sqoop.schema.Schema; import org.apache.sqoop.schema.type.FixedPoint; import org.apache.sqoop.schema.type.FloatingPoint; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; -@RunWith(Parameterized.class) public class TestMatching { private static final int START_PARTITION = 1; private static final int NUMBER_OF_PARTITIONS = 1; @@ -73,17 +71,14 @@ public class TestMatching { private Schema from; private Schema to; - public TestMatching(Schema from, - Schema to) - throws Exception { + @Factory(dataProvider="test-matching-data") + public TestMatching(Schema from, Schema to) { this.from = from; this.to = to; - - System.out.println("Testing with Schemas\n\tFROM: " + this.from + "\n\tTO: " + this.to); } - @Parameterized.Parameters - public static Collection data() { + @DataProvider(name="test-matching-data", parallel=true) + public static Object[][] data() { List parameters = new ArrayList(); Schema emptyFrom = new Schema("FROM-EMPTY"); @@ -125,7 +120,7 @@ public static Collection data() { to2 }); - return parameters; + return parameters.toArray(new Object[0][]); } @SuppressWarnings("deprecation") @@ -147,17 +142,17 @@ public void testSchemaMatching() throws Exception { DummyOutputFormat.class); if (from.getName().split("-")[1].equals("EMPTY")) { if (to.getName().split("-")[1].equals("EMPTY")) { - Assert.assertEquals("Job succeeded!", false, success); + assertEquals("Job succeeded!", false, success); } else { - Assert.assertEquals("Job failed!", true, success); + assertEquals("Job failed!", true, success); } } else { if (to.getName().split("-")[1].equals("EMPTY")) { - Assert.assertEquals("Job failed!", true, success); + assertEquals("Job failed!", true, success); } else if (from.getName().split("-")[1].equals(to.getName().split("-")[1])) { - Assert.assertEquals("Job failed!", true, success); + assertEquals("Job failed!", true, success); } else { - Assert.assertEquals("Job succeeded!", false, success); + assertEquals("Job succeeded!", false, success); } } } @@ -183,7 +178,7 @@ public void testSchemalessFromAndTo() throws UnsupportedEncodingException { Object[] validateObj = dataFormat.getObjectData(); assertEquals(testData, validateCSV); - assertEquals(testObject, validateObj); + assertArrayEquals(testObject, validateObj); // Setting data as Object dataFormat.setObjectData(testObject); @@ -192,7 +187,7 @@ public void testSchemalessFromAndTo() throws UnsupportedEncodingException { validateObj = dataFormat.getObjectData(); assertEquals(testData, validateCSV); - assertEquals(testObjectCopy, validateObj); + assertArrayEquals(testObjectCopy, validateObj); } public static class DummyPartition extends Partition { diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/io/TestSqoopWritable.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/io/TestSqoopWritable.java index 79d6a8fa..087d7d3b 100644 --- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/io/TestSqoopWritable.java +++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/io/TestSqoopWritable.java @@ -18,10 +18,10 @@ */ package org.apache.sqoop.job.io; -import static org.junit.Assert.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.testng.Assert.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -34,15 +34,15 @@ import org.apache.sqoop.connector.idf.CSVIntermediateDataFormat; import org.apache.sqoop.connector.idf.IntermediateDataFormat; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; public class TestSqoopWritable { private SqoopWritable writable; private IntermediateDataFormat idfMock; - @Before + @BeforeMethod public void setUp() { idfMock = mock(IntermediateDataFormat.class); writable = new SqoopWritable(idfMock); diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestMRConfigurationUtils.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestMRConfigurationUtils.java index 70ea6d45..a3e6dee0 100644 --- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestMRConfigurationUtils.java +++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestMRConfigurationUtils.java @@ -17,7 +17,7 @@ */ package org.apache.sqoop.job.mr; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -31,8 +31,8 @@ import org.apache.sqoop.schema.NullSchema; import org.apache.sqoop.schema.Schema; import org.apache.sqoop.schema.type.Text; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; /** * Current tests are using mockito to propagate credentials from hadoop Job object @@ -44,7 +44,7 @@ public class TestMRConfigurationUtils { Job job; JobConf jobConfSpy; - @Before + @BeforeMethod public void setUp() throws Exception { setUpHadoopJob(); setUpHadoopJobConf(); diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestSqoopOutputFormatLoadExecutor.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestSqoopOutputFormatLoadExecutor.java index f5f627d6..7ddaa10b 100644 --- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestSqoopOutputFormatLoadExecutor.java +++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestSqoopOutputFormatLoadExecutor.java @@ -40,9 +40,9 @@ import org.apache.sqoop.job.util.MRJobTestUtil; import org.apache.sqoop.schema.NullSchema; import org.apache.sqoop.submission.counter.SqoopCounters; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.util.ConcurrentModificationException; import java.util.concurrent.BrokenBarrierException; @@ -149,7 +149,7 @@ private IntermediateDataFormat getIDF(){ return new CSVIntermediateDataFormat(); } - @Before + @BeforeMethod public void setUp() { conf = new Configuration(); conf.setIfUnset(MRJobConstants.TO_INTERMEDIATE_DATA_FORMAT, @@ -161,7 +161,7 @@ public void setUp() { when(jobContextMock.getConfiguration()).thenReturn(testConf); } - @Test(expected = BrokenBarrierException.class) + @Test(expectedExceptions = BrokenBarrierException.class) public void testWhenLoaderThrows() throws Throwable { conf.set(MRJobConstants.JOB_ETL_LOADER, ThrowingLoader.class.getName()); SqoopOutputFormatLoadExecutor executor = new SqoopOutputFormatLoadExecutor(jobContextMock, @@ -205,7 +205,7 @@ public void testSuccessfulContinuousLoader() throws Throwable { verify(jobContextMock, times(1)).getCounter(SqoopCounters.ROWS_WRITTEN); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testSuccessfulLoader() throws Throwable { SqoopOutputFormatLoadExecutor executor = new SqoopOutputFormatLoadExecutor(jobContextMock, GoodLoader.class.getName(), getIDF(), getMatcher()); @@ -230,7 +230,7 @@ public void testSuccessfulLoader() throws Throwable { verify(jobContextMock, times(1)).getCounter(SqoopCounters.ROWS_WRITTEN); } - @Test(expected = ConcurrentModificationException.class) + @Test(expectedExceptions = ConcurrentModificationException.class) public void testThrowingContinuousLoader() throws Throwable { conf.set(MRJobConstants.JOB_ETL_LOADER, ThrowingContinuousLoader.class.getName()); SqoopOutputFormatLoadExecutor executor = new SqoopOutputFormatLoadExecutor(jobContextMock, diff --git a/pom.xml b/pom.xml index d1f0a45c..3297c00e 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,7 @@ limitations under the License. 2.6.0 11.0.2 1.1 - 4.11 + 6.8.13 1.9.5 1.5.6 1.2.16 @@ -144,7 +144,7 @@ limitations under the License. org.apache.maven.plugins maven-surefire-plugin - org.apache.sqoop.common.test.categories.SlowTests + slow @@ -160,7 +160,7 @@ limitations under the License. org.apache.maven.plugins maven-surefire-plugin - org.apache.sqoop.common.test.categories.SlowTests + slow @@ -462,9 +462,9 @@ limitations under the License. ${servlet.version} - junit - junit - ${junit.version} + org.testng + testng + ${testng.version} log4j @@ -549,7 +549,7 @@ limitations under the License. org.powermock - powermock-module-junit4 + powermock-module-testng ${powermock.version} test @@ -660,6 +660,7 @@ limitations under the License. **.patch patch-process/* .metadata/ + **/target/* @@ -672,15 +673,21 @@ limitations under the License. org.apache.maven.plugins maven-surefire-plugin - 2.13 + 2.14 - always + 1 + false 3600 true -Xms512m -Xmx2g -XX:MaxPermSize=1024m + + + usedefaultlisteners + false + + - diff --git a/repository/repository-common/pom.xml b/repository/repository-common/pom.xml index 37378c66..c7401174 100644 --- a/repository/repository-common/pom.xml +++ b/repository/repository-common/pom.xml @@ -43,8 +43,8 @@ limitations under the License. - junit - junit + org.testng + testng test diff --git a/repository/repository-derby/pom.xml b/repository/repository-derby/pom.xml index 9be96db3..2a3b8fcd 100644 --- a/repository/repository-derby/pom.xml +++ b/repository/repository-derby/pom.xml @@ -53,8 +53,8 @@ limitations under the License. - junit - junit + org.testng + testng test diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java index 6cb3eb07..1b6bdc0d 100644 --- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java +++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java @@ -20,7 +20,7 @@ import static org.apache.sqoop.repository.derby.DerbySchemaUpgradeQuery.*; import static org.apache.sqoop.repository.derby.DerbySchemaCreateQuery.*; import static org.apache.sqoop.repository.derby.DerbySchemaInsertUpdateDeleteSelectQuery.*; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import java.sql.Connection; import java.sql.DriverManager; @@ -46,8 +46,8 @@ import org.apache.sqoop.model.MMapInput; import org.apache.sqoop.model.MStringInput; import org.apache.sqoop.model.MToConfig; -import org.junit.After; -import org.junit.Before; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; /** * Abstract class with convenience methods for testing derby repository. @@ -60,14 +60,14 @@ abstract public class DerbyTestCase { private Connection connection; - @Before + @BeforeMethod public void setUp() throws Exception { // Create link to the database Class.forName(DERBY_DRIVER).newInstance(); connection = DriverManager.getConnection(getStartJdbcUrl()); } - @After + @AfterMethod public void tearDown() throws Exception { // Close active link if (connection != null) { diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java index efc44181..248873bf 100644 --- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java +++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java @@ -18,14 +18,14 @@ package org.apache.sqoop.repository.derby; import org.apache.sqoop.model.MConnector; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; /** * Test connector methods on Derby repository. @@ -34,7 +34,7 @@ public class TestConnectorHandling extends DerbyTestCase { DerbyRepositoryHandler handler; - @Before + @BeforeMethod public void setUp() throws Exception { super.setUp(); handler = new DerbyRepositoryHandler(); diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverHandling.java index 25a0093f..91d8b929 100644 --- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverHandling.java +++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverHandling.java @@ -17,14 +17,14 @@ */ package org.apache.sqoop.repository.derby; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; import org.apache.sqoop.model.MDriver; import org.apache.sqoop.model.MDriverConfig; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; /** * Test driver methods on Derby repository. @@ -34,7 +34,7 @@ public class TestDriverHandling extends DerbyTestCase { private static final Object CURRENT_DRIVER_VERSION = "1"; DerbyRepositoryHandler handler; - @Before + @BeforeMethod public void setUp() throws Exception { super.setUp(); handler = new DerbyRepositoryHandler(); diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java index 71cc7632..2cbe255d 100644 --- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java +++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java @@ -17,9 +17,9 @@ */ package org.apache.sqoop.repository.derby; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNotSame; import java.util.HashMap; import java.util.LinkedList; @@ -38,8 +38,8 @@ import org.apache.sqoop.model.MMapInput; import org.apache.sqoop.model.MPersistableEntity; import org.apache.sqoop.model.MStringInput; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; /** * Test proper support of all available model types. @@ -48,7 +48,7 @@ public class TestInputTypes extends DerbyTestCase { DerbyRepositoryHandler handler; - @Before + @BeforeMethod public void setUp() throws Exception { super.setUp(); diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java index 309e6b25..3cc6928a 100644 --- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java +++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java @@ -17,12 +17,12 @@ */ package org.apache.sqoop.repository.derby; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.sql.Connection; import java.util.HashMap; @@ -37,8 +37,8 @@ import org.apache.sqoop.model.MMapInput; import org.apache.sqoop.model.MStringInput; import org.apache.sqoop.repository.common.CommonRepositoryError; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; /** * Test job methods on Derby repository. @@ -48,7 +48,7 @@ public class TestJobHandling extends DerbyTestCase { DerbyRepositoryHandler handler; Connection derbyConnection; - @Before + @BeforeMethod public void setUp() throws Exception { super.setUp(); derbyConnection = getDerbyDatabaseConnection(); @@ -218,7 +218,7 @@ public void testCreateJob() throws Exception { assertCountForTable("SQOOP.SQ_JOB_INPUT", 12); } - @Test(expected=SqoopException.class) + @Test(expectedExceptions=SqoopException.class) public void testCreateDuplicateJob() throws Exception { // Duplicate jobs MJob job = getJob(); diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java index 6274d114..1c96deb7 100644 --- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java +++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java @@ -17,12 +17,12 @@ */ package org.apache.sqoop.repository.derby; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.util.List; @@ -32,8 +32,8 @@ import org.apache.sqoop.model.MMapInput; import org.apache.sqoop.model.MStringInput; import org.apache.sqoop.repository.common.CommonRepositoryError; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; /** * Test link methods on Derby repository. @@ -42,7 +42,7 @@ public class TestLinkHandling extends DerbyTestCase { DerbyRepositoryHandler handler; - @Before + @BeforeMethod public void setUp() throws Exception { super.setUp(); @@ -200,7 +200,7 @@ public void testCreateLink() throws Exception { assertCountForTable("SQOOP.SQ_LINK_INPUT", 4); } - @Test(expected = SqoopException.class) + @Test(expectedExceptions = SqoopException.class) public void testCreateDuplicateLink() throws Exception { MLink link = getLink(); fillLink(link); diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestRepositoryUpgrade.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestRepositoryUpgrade.java index 31154af2..b53aeffc 100644 --- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestRepositoryUpgrade.java +++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestRepositoryUpgrade.java @@ -17,20 +17,20 @@ */ package org.apache.sqoop.repository.derby; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; import java.sql.Connection; import java.sql.SQLIntegrityConstraintViolationException; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; public class TestRepositoryUpgrade extends DerbyTestCase { DerbyRepositoryHandler handler; - @Before + @BeforeMethod public void setUp() throws Exception { super.setUp(); handler = new TestDerbyRepositoryHandler(); @@ -63,7 +63,7 @@ public void testDoubleUpdateRepositorySchema() throws Exception { assertTrue(handler.isRepositorySuitableForUse(getDerbyDatabaseConnection())); } - @Test(expected = SQLIntegrityConstraintViolationException.class) + @Test(expectedExceptions = SQLIntegrityConstraintViolationException.class) public void testUpgradeVersion4WithNonUniqueJobNameFailure() throws Exception { super.createOrUpgradeSchema(4); // try loading duplicate job names in version 4 and it should throw an @@ -71,7 +71,7 @@ public void testUpgradeVersion4WithNonUniqueJobNameFailure() throws Exception { super.loadNonUniqueJobsInVersion4(); } - @Test(expected = SQLIntegrityConstraintViolationException.class) + @Test(expectedExceptions = SQLIntegrityConstraintViolationException.class) public void testUpgradeVersion4WithNonUniqueLinkNamesAdded() throws Exception { super.createOrUpgradeSchema(4); // try loading duplicate link names in version 4 and it should throw an @@ -79,7 +79,7 @@ public void testUpgradeVersion4WithNonUniqueLinkNamesAdded() throws Exception { super.loadNonUniqueLinksInVersion4(); } - @Test(expected = SQLIntegrityConstraintViolationException.class) + @Test(expectedExceptions = SQLIntegrityConstraintViolationException.class) public void testUpgradeVersion4WithNonUniqueConfigurableNamesAdded() throws Exception { super.createOrUpgradeSchema(4); // try loading duplicate configurable names in version 4 and it should throw @@ -87,7 +87,7 @@ public void testUpgradeVersion4WithNonUniqueConfigurableNamesAdded() throws Exce super.loadNonUniqueConfigurablesInVersion4(); } - @Test(expected = SQLIntegrityConstraintViolationException.class) + @Test(expectedExceptions = SQLIntegrityConstraintViolationException.class) public void testUpgradeVersion4WithNonUniqueConfigNameAndTypeAdded() throws Exception { super.createOrUpgradeSchema(4); super.addConnectorB(); @@ -115,7 +115,7 @@ public void testUpgradeVersion4WithNonUniqueConfigNameAndTypeButUniqueConfigurab super.loadNonUniqueConfigNameAndTypeButUniqueConfigurableInVersion4(); } - @Test(expected = SQLIntegrityConstraintViolationException.class) + @Test(expectedExceptions = SQLIntegrityConstraintViolationException.class) public void testUpgradeVersion4WithNonUniqueInputNameAndTypeAdded() throws Exception { super.createOrUpgradeSchema(4); super.addConnectorB(); diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java index b4792668..523ddc7b 100644 --- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java +++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java @@ -22,14 +22,14 @@ import org.apache.sqoop.submission.counter.Counter; import org.apache.sqoop.submission.counter.CounterGroup; import org.apache.sqoop.submission.counter.Counters; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.util.Calendar; import java.util.Date; import java.util.List; -import static org.junit.Assert.*; +import static org.testng.Assert.*; /** * @@ -38,7 +38,7 @@ public class TestSubmissionHandling extends DerbyTestCase { DerbyRepositoryHandler handler; - @Before + @BeforeMethod public void setUp() throws Exception { super.setUp(); @@ -130,8 +130,8 @@ public void testCreateSubmission() throws Exception { assertEquals(1, submission.getJobId()); assertEquals(SubmissionStatus.RUNNING, submission.getStatus()); - assertEquals(creationDate, submission.getCreationDate()); - assertEquals(updateDate, submission.getLastUpdateDate()); + assertEquals(creationDate.getTime(), submission.getCreationDate().getTime()); + assertEquals(updateDate.getTime(), submission.getLastUpdateDate().getTime()); assertEquals("job-x", submission.getExternalJobId()); assertEquals("http://somewhere", submission.getExternalLink()); assertEquals("RuntimeException", submission.getError().getErrorSummary()); diff --git a/repository/repository-postgresql/pom.xml b/repository/repository-postgresql/pom.xml index e5e5ec8b..0ee90817 100644 --- a/repository/repository-postgresql/pom.xml +++ b/repository/repository-postgresql/pom.xml @@ -59,9 +59,9 @@ limitations under the License. - junit - junit - test + org.testng + testng + ${testng.version} diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestCase.java b/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestCase.java index 5d80dce3..ea199d4b 100644 --- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestCase.java +++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestCase.java @@ -19,10 +19,10 @@ import org.apache.sqoop.common.test.db.DatabaseProvider; import org.apache.sqoop.common.test.db.PostgreSQLProvider; -import org.junit.After; -import org.junit.Assume; -import org.junit.Before; -import org.junit.BeforeClass; +import org.testng.SkipException; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; /** * Abstract class with convenience methods for testing postgresql repository. @@ -33,25 +33,25 @@ abstract public class PostgresqlTestCase { public static PostgresqlTestUtils utils; public PostgresqlRepositoryHandler handler; - @BeforeClass + @Test public static void setUpClass() { provider = new PostgreSQLProvider(); utils = new PostgresqlTestUtils(provider); } - @Before + @BeforeMethod public void setUp() throws Exception { try { provider.start(); } catch (RuntimeException e) { - Assume.assumeTrue(false); + throw new SkipException("Cannot connect to provider.", e); } handler = new PostgresqlRepositoryHandler(); handler.createOrUpgradeRepository(provider.getConnection()); } - @After + @AfterMethod public void tearDown() throws Exception { provider.dropSchema("sqoop"); provider.stop(); diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/TestStructure.java b/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/TestStructure.java index 2da19bc9..6075de45 100644 --- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/TestStructure.java +++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/TestStructure.java @@ -17,7 +17,7 @@ */ package org.apache.sqoop.repository.postgresql; -import org.junit.Test; +import org.testng.annotations.Test; /** * Test connector methods on PostgreSQL repository. diff --git a/submission/mapreduce/pom.xml b/submission/mapreduce/pom.xml index 7b454922..b0fbb71f 100644 --- a/submission/mapreduce/pom.xml +++ b/submission/mapreduce/pom.xml @@ -41,8 +41,8 @@ limitations under the License. - junit - junit + org.testng + testng test diff --git a/test/pom.xml b/test/pom.xml index f74ee3c9..373b89c8 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -31,8 +31,8 @@ limitations under the License. - junit - junit + org.testng + testng diff --git a/test/src/main/java/org/apache/sqoop/test/asserts/HdfsAsserts.java b/test/src/main/java/org/apache/sqoop/test/asserts/HdfsAsserts.java index d8f2b8d5..adc638a7 100644 --- a/test/src/main/java/org/apache/sqoop/test/asserts/HdfsAsserts.java +++ b/test/src/main/java/org/apache/sqoop/test/asserts/HdfsAsserts.java @@ -32,8 +32,8 @@ import java.util.List; import java.util.Set; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.fail; /** * Assert methods suitable for checking HDFS files and directories. diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java index 9a76c4b3..e98d0913 100644 --- a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java +++ b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.test.testcases; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotSame; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.mapred.JobConf; @@ -40,8 +40,8 @@ import org.apache.sqoop.test.hadoop.HadoopMiniClusterRunner; import org.apache.sqoop.test.hadoop.HadoopRunnerFactory; import org.apache.sqoop.validation.Status; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; /** * Base test case suitable for connector testing. diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/KafkaConnectorTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/KafkaConnectorTestCase.java index 804516b9..cc6724e3 100644 --- a/test/src/main/java/org/apache/sqoop/test/testcases/KafkaConnectorTestCase.java +++ b/test/src/main/java/org/apache/sqoop/test/testcases/KafkaConnectorTestCase.java @@ -22,9 +22,9 @@ import org.apache.sqoop.model.MConfigList; import org.apache.sqoop.model.MJob; import org.apache.sqoop.model.MLink; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; +import org.testng.annotations.AfterClass; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.apache.sqoop.common.test.kafka.TestUtil; import java.io.IOException; diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java index 0b0a0a24..ce748943 100644 --- a/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java +++ b/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; import org.apache.commons.io.FileUtils; import org.apache.hadoop.fs.FileSystem; @@ -31,12 +32,10 @@ import org.apache.sqoop.test.hadoop.HadoopLocalRunner; import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster; import org.apache.sqoop.test.utils.HdfsUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.rules.TestName; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeClass; /** * Basic test case that will bootstrap Sqoop server running in external Tomcat @@ -45,7 +44,7 @@ abstract public class TomcatTestCase { private static final Logger LOG = Logger.getLogger(TomcatTestCase.class); - @Rule public TestName name = new TestName(); + public String name; /** * Temporary base path that will be used for tests. @@ -102,10 +101,15 @@ public static void startHadoop() throws Exception { LOG.debug("HDFS Client: " + hdfsClient); } - @Before + @BeforeMethod + public void findMethodName(Method method) { + name = method.getName(); + } + + @BeforeMethod public void startServer() throws Exception { // Get and set temporary path in hadoop cluster. - tmpPath = HdfsUtils.joinPathFragments(TMP_PATH_BASE, getClass().getName(), name.getMethodName()); + tmpPath = HdfsUtils.joinPathFragments(TMP_PATH_BASE, getClass().getName(), name); FileUtils.deleteDirectory(new File(tmpPath)); LOG.debug("Temporary Directory: " + tmpPath); @@ -118,7 +122,7 @@ public void startServer() throws Exception { client = new SqoopClient(getServerUrl()); } - @After + @AfterMethod public void stopServer() throws Exception { cluster.stop(); } @@ -171,7 +175,7 @@ public String getServerUrl() { * @return */ public String getMapreduceDirectory() { - return HdfsUtils.joinPathFragments(hadoopCluster.getTestDirectory(), getClass().getName(), name.getMethodName()); + return HdfsUtils.joinPathFragments(hadoopCluster.getTestDirectory(), getClass().getName(), name); } /** diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java index b1b3b16b..f82abc70 100644 --- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java +++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java @@ -23,9 +23,9 @@ import org.apache.sqoop.model.MLink; import org.apache.sqoop.model.MConfigList; import org.apache.sqoop.model.MJob; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** * diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java index e482ac59..85b9d2de 100644 --- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java +++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java @@ -17,7 +17,7 @@ */ package org.apache.sqoop.integration.connector.jdbc.generic; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.assertTrue; import org.apache.sqoop.common.Direction; import org.apache.sqoop.connector.hdfs.configuration.ToFormat; @@ -27,7 +27,7 @@ import org.apache.sqoop.model.MLink; import org.apache.sqoop.model.MSubmission; import org.apache.sqoop.test.testcases.ConnectorTestCase; -import org.junit.Test; +import org.testng.annotations.Test; /** * Import simple table with various configurations. diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java index bd349114..352fb269 100644 --- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java +++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java @@ -17,6 +17,7 @@ */ package org.apache.sqoop.integration.connector.jdbc.generic; +import com.google.common.collect.Iterables; import org.apache.sqoop.common.Direction; import org.apache.sqoop.connector.hdfs.configuration.ToFormat; import org.apache.sqoop.model.MDriverConfig; @@ -25,15 +26,15 @@ import org.apache.sqoop.model.MJob; import org.apache.sqoop.test.testcases.ConnectorTestCase; import org.apache.sqoop.test.utils.ParametrizedUtils; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.Test; +import org.testng.ITest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; /** * */ -@RunWith(Parameterized.class) -public class PartitionerTest extends ConnectorTestCase { +public class PartitionerTest extends ConnectorTestCase implements ITest { /** * Columns that we will use as partition column with maximal number of @@ -54,21 +55,27 @@ public class PartitionerTest extends ConnectorTestCase { 3, 5, 10, 13, }; - @Parameterized.Parameters(name = "{0}-{1}-{2}") - public static Iterable data() { - return ParametrizedUtils.crossProduct(COLUMNS, EXTRACTORS); - } - private String partitionColumn; private int maxOutputFiles; private int extractors; + @Factory(dataProvider="partitioner-integration-test") public PartitionerTest(String partitionColumn, int expectedOutputFiles, int extractors) { this.partitionColumn = partitionColumn; this.maxOutputFiles = expectedOutputFiles; this.extractors = extractors; } + @Override + public String getTestName() { + return "PartitionerTest-" + this.partitionColumn + "-" + this.maxOutputFiles + "-" + this.extractors; + } + + @DataProvider(name="partitioner-integration-test", parallel=true) + public static Object[][] data() { + return Iterables.toArray(ParametrizedUtils.crossProduct(COLUMNS, EXTRACTORS), Object[].class); + } + @Test public void testSplitter() throws Exception { createAndLoadTableUbuntuReleases(); diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java index f42fa322..b648870b 100644 --- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java +++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java @@ -17,7 +17,7 @@ */ package org.apache.sqoop.integration.connector.jdbc.generic; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; import org.apache.sqoop.common.Direction; import org.apache.sqoop.model.MConfigList; @@ -25,7 +25,7 @@ import org.apache.sqoop.model.MLink; import org.apache.sqoop.test.data.Cities; import org.apache.sqoop.test.testcases.ConnectorTestCase; -import org.junit.Test; +import org.testng.annotations.Test; /** * diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromHDFSToKafkaTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromHDFSToKafkaTest.java index dabb69d2..83273f1b 100644 --- a/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromHDFSToKafkaTest.java +++ b/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromHDFSToKafkaTest.java @@ -21,7 +21,7 @@ import org.apache.sqoop.model.MJob; import org.apache.sqoop.model.MLink; import org.apache.sqoop.test.testcases.KafkaConnectorTestCase; -import org.junit.Test; +import org.testng.annotations.Test; public class FromHDFSToKafkaTest extends KafkaConnectorTestCase { diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromRDBMSToKafkaTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromRDBMSToKafkaTest.java index 93d657c7..04d28354 100644 --- a/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromRDBMSToKafkaTest.java +++ b/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromRDBMSToKafkaTest.java @@ -23,7 +23,7 @@ import org.apache.sqoop.model.MJob; import org.apache.sqoop.model.MLink; import org.apache.sqoop.test.testcases.KafkaConnectorTestCase; -import org.junit.Test; +import org.testng.annotations.Test; public class FromRDBMSToKafkaTest extends KafkaConnectorTestCase { diff --git a/test/src/test/java/org/apache/sqoop/integration/repository/derby/upgrade/DerbyRepositoryUpgradeTest.java b/test/src/test/java/org/apache/sqoop/integration/repository/derby/upgrade/DerbyRepositoryUpgradeTest.java index 0c25f184..a687c168 100644 --- a/test/src/test/java/org/apache/sqoop/integration/repository/derby/upgrade/DerbyRepositoryUpgradeTest.java +++ b/test/src/test/java/org/apache/sqoop/integration/repository/derby/upgrade/DerbyRepositoryUpgradeTest.java @@ -22,16 +22,16 @@ import org.apache.sqoop.test.testcases.TomcatTestCase; import org.apache.sqoop.test.utils.CompressionUtils; import org.apache.sqoop.test.utils.HdfsUtils; -import org.junit.Test; +import org.testng.annotations.Test; import org.apache.log4j.Logger; import java.io.InputStream; import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; /** * Abstract test case for testing upgrade from previous version to the "most recent one". diff --git a/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java b/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java index 055bc3d7..9b3babd5 100644 --- a/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java +++ b/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java @@ -26,41 +26,39 @@ import org.apache.sqoop.model.MConfigList; import org.apache.sqoop.model.MJob; import org.apache.sqoop.test.testcases.ConnectorTestCase; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.Test; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; /** * Ensure that server will reject starting job when either job itself * or corresponding link is disabled. */ -@RunWith(Parameterized.class) public class SubmissionWithDisabledModelObjectsTest extends ConnectorTestCase { - @Parameterized.Parameters(name = "con({0}) job({1})") - public static Iterable data() { - return Arrays.asList(new Object[][]{ - {true, false}, - {false, true}, - {false, false}, - }); - } - private boolean enabledLink; private boolean enabledJob; + @Factory(dataProvider="submission-with-disable-model-objects-integration-test") public SubmissionWithDisabledModelObjectsTest(boolean enabledLink, boolean enabledJob) { this.enabledLink = enabledLink; this.enabledJob = enabledJob; } + @DataProvider(name="submission-with-disable-model-objects-integration-test", parallel=true) + public static Object[][] data() { + return new Object[][]{ + {true, false}, + {false, true}, + {false, false}, + }; + } + @Test public void testWithDisabledObjects() throws Exception { createAndLoadTableCities(); diff --git a/test/src/test/java/org/apache/sqoop/integration/server/VersionTest.java b/test/src/test/java/org/apache/sqoop/integration/server/VersionTest.java index b3254bd1..a54492eb 100644 --- a/test/src/test/java/org/apache/sqoop/integration/server/VersionTest.java +++ b/test/src/test/java/org/apache/sqoop/integration/server/VersionTest.java @@ -21,9 +21,9 @@ import org.apache.sqoop.common.VersionInfo; import org.apache.sqoop.test.testcases.TomcatTestCase; import org.apache.sqoop.json.VersionBean; -import org.junit.Test; +import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; /** * Basic test to check that server is working and returning correct version info. diff --git a/tomcat/pom.xml b/tomcat/pom.xml index 91616bb4..3eb150b1 100644 --- a/tomcat/pom.xml +++ b/tomcat/pom.xml @@ -32,8 +32,8 @@ limitations under the License. - junit - junit + org.testng + testng test diff --git a/tools/pom.xml b/tools/pom.xml index 01e1a5f2..65fd40ca 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -31,8 +31,8 @@ limitations under the License. - junit - junit + org.testng + testng org.apache.sqoop