SQOOP-3405: Refactor: break up Parameterized tests on a per database basis
authorroot <root@vasassqoop.vpc.cloudera.com>
Thu, 22 Nov 2018 13:43:21 +0000 (05:43 -0800)
committerSzabolcs Vasas <vasas@apache.org>
Thu, 22 Nov 2018 14:41:14 +0000 (15:41 +0100)
(Fero Szabo via Szabolcs Vasas)

15 files changed:
src/test/org/apache/sqoop/importjob/DatabaseAdapterFactory.java [new file with mode: 0644]
src/test/org/apache/sqoop/importjob/configuration/MysqlImportJobTestConfiguration.java [moved from src/test/org/apache/sqoop/importjob/configuration/MySQLImportJobTestConfiguration.java with 97% similarity]
src/test/org/apache/sqoop/importjob/configuration/SqlServerImportJobTestConfiguration.java [moved from src/test/org/apache/sqoop/importjob/configuration/MSSQLServerImportJobTestConfiguration.java with 94% similarity]
src/test/org/apache/sqoop/importjob/numerictypes/MysqlNumericTypesImportTest.java [new file with mode: 0644]
src/test/org/apache/sqoop/importjob/numerictypes/NumericTypesImportTestBase.java [moved from src/test/org/apache/sqoop/importjob/NumericTypesImportTest.java with 76% similarity]
src/test/org/apache/sqoop/importjob/numerictypes/OracleNumericTypesImportTest.java [new file with mode: 0644]
src/test/org/apache/sqoop/importjob/numerictypes/PostgresNumericTypesImportTest.java [new file with mode: 0644]
src/test/org/apache/sqoop/importjob/numerictypes/SqlServerNumericTypesImportTest.java [new file with mode: 0644]
src/test/org/apache/sqoop/importjob/splitby/MysqlSplitByImportTest.java [new file with mode: 0644]
src/test/org/apache/sqoop/importjob/splitby/OracleSplitByImportTest.java [new file with mode: 0644]
src/test/org/apache/sqoop/importjob/splitby/PostgresSplitByImportTest.java [new file with mode: 0644]
src/test/org/apache/sqoop/importjob/splitby/SplitByImportTestBase.java [moved from src/test/org/apache/sqoop/importjob/SplitByImportTest.java with 71% similarity]
src/test/org/apache/sqoop/importjob/splitby/SqlServerSplitByImportTest.java [new file with mode: 0644]
src/test/org/apache/sqoop/testutil/adapter/MysqlDatabaseAdapter.java [moved from src/test/org/apache/sqoop/testutil/adapter/MySqlDatabaseAdapter.java with 96% similarity]
src/test/org/apache/sqoop/testutil/adapter/SqlServerDatabaseAdapter.java [moved from src/test/org/apache/sqoop/testutil/adapter/MSSQLServerDatabaseAdapter.java with 96% similarity]

diff --git a/src/test/org/apache/sqoop/importjob/DatabaseAdapterFactory.java b/src/test/org/apache/sqoop/importjob/DatabaseAdapterFactory.java
new file mode 100644 (file)
index 0000000..0e9cdc3
--- /dev/null
@@ -0,0 +1,26 @@
+/**
+ * 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.importjob;
+
+import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
+
+public interface DatabaseAdapterFactory {
+
+  DatabaseAdapter createAdapter();
+}
@@ -21,7 +21,7 @@ package org.apache.sqoop.importjob.configuration;
 import java.util.ArrayList;
 import java.util.List;
 
-public class MySQLImportJobTestConfiguration implements ImportJobTestConfiguration, AvroTestConfiguration, ParquetTestConfiguration {
+public class MysqlImportJobTestConfiguration implements ImportJobTestConfiguration, AvroTestConfiguration, ParquetTestConfiguration {
 
   @Override
   public String[] getTypes() {
@@ -21,7 +21,7 @@ package org.apache.sqoop.importjob.configuration;
 import java.util.ArrayList;
 import java.util.List;
 
-public class MSSQLServerImportJobTestConfiguration implements ImportJobTestConfiguration, AvroTestConfiguration, ParquetTestConfiguration {
+public class SqlServerImportJobTestConfiguration implements ImportJobTestConfiguration, AvroTestConfiguration, ParquetTestConfiguration {
 
   @Override
   public String[] getTypes() {
diff --git a/src/test/org/apache/sqoop/importjob/numerictypes/MysqlNumericTypesImportTest.java b/src/test/org/apache/sqoop/importjob/numerictypes/MysqlNumericTypesImportTest.java
new file mode 100644 (file)
index 0000000..e39be38
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * 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.importjob.numerictypes;
+
+import org.apache.sqoop.importjob.configuration.MysqlImportJobTestConfiguration;
+import org.apache.sqoop.testcategories.thirdpartytest.MysqlTest;
+import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
+import org.apache.sqoop.testutil.adapter.MysqlDatabaseAdapter;
+import org.junit.experimental.categories.Category;
+
+@Category(MysqlTest.class)
+public class MysqlNumericTypesImportTest extends NumericTypesImportTestBase {
+
+  @Override
+  public DatabaseAdapter createAdapter() {
+    return new MysqlDatabaseAdapter();
+  }
+
+  public MysqlNumericTypesImportTest() {
+    super(new MysqlImportJobTestConfiguration(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY);
+  }
+}
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.sqoop.importjob;
+package org.apache.sqoop.importjob.numerictypes;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -25,46 +25,31 @@ import org.apache.hadoop.fs.Path;
 import org.apache.parquet.schema.MessageType;
 import org.apache.parquet.schema.OriginalType;
 import org.apache.sqoop.SqoopOptions;
+import org.apache.sqoop.importjob.DatabaseAdapterFactory;
 import org.apache.sqoop.importjob.configuration.AvroTestConfiguration;
-import org.apache.sqoop.importjob.configuration.MSSQLServerImportJobTestConfiguration;
-import org.apache.sqoop.importjob.configuration.MySQLImportJobTestConfiguration;
-import org.apache.sqoop.importjob.configuration.OracleImportJobTestConfiguration;
 import org.apache.sqoop.importjob.configuration.ParquetTestConfiguration;
-import org.apache.sqoop.importjob.configuration.PostgresqlImportJobTestConfigurationForNumeric;
 import org.apache.sqoop.testcategories.thirdpartytest.ThirdPartyTest;
 import org.apache.sqoop.testutil.ArgumentArrayBuilder;
 import org.apache.sqoop.testutil.AvroTestUtils;
 import org.apache.sqoop.testutil.ImportJobTestCase;
 import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
-import org.apache.sqoop.testutil.adapter.MSSQLServerDatabaseAdapter;
-import org.apache.sqoop.testutil.adapter.MySqlDatabaseAdapter;
-import org.apache.sqoop.testutil.adapter.OracleDatabaseAdapter;
-import org.apache.sqoop.testutil.adapter.PostgresDatabaseAdapter;
-import org.apache.sqoop.importjob.configuration.OracleImportJobTestConfigurationForNumber;
-import org.apache.sqoop.importjob.configuration.PostgresqlImportJobTestConfigurationPaddingShouldSucceed;
 import org.apache.sqoop.util.ParquetReader;
-import org.apache.sqoop.util.BlockJUnit4ClassRunnerWithParametersFactory;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
 
 import java.io.IOException;
 import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.List;
 
-import static org.junit.Assert.assertEquals;
 import static org.apache.sqoop.SqoopOptions.FileLayout.AvroDataFile;
 import static org.apache.sqoop.SqoopOptions.FileLayout.ParquetFile;
+import static org.junit.Assert.assertEquals;
 
-@RunWith(Parameterized.class)
-@Parameterized.UseParametersRunnerFactory(BlockJUnit4ClassRunnerWithParametersFactory.class)
 @Category(ThirdPartyTest.class)
 /**
  * This test covers the behavior of the Avro import for fixed point decimal types, i.e. NUMBER, NUMERIC
@@ -80,9 +65,9 @@ import static org.apache.sqoop.SqoopOptions.FileLayout.ParquetFile;
  * 2. Decimal padding during avro or parquet import
  * In case of Oracle and Postgres, Sqoop has to pad the values with 0s to avoid errors.
  */
-public class NumericTypesImportTest<T extends AvroTestConfiguration & ParquetTestConfiguration> extends ImportJobTestCase {
+public abstract class NumericTypesImportTestBase<T extends AvroTestConfiguration & ParquetTestConfiguration> extends ImportJobTestCase implements DatabaseAdapterFactory {
 
-  public static final Log LOG = LogFactory.getLog(NumericTypesImportTest.class.getName());
+  public static final Log LOG = LogFactory.getLog(NumericTypesImportTestBase.class.getName());
 
   private Configuration conf = new Configuration();
 
@@ -93,30 +78,17 @@ public class NumericTypesImportTest<T extends AvroTestConfiguration & ParquetTes
 
   // Constants for the basic test case, that doesn't use extra arguments
   // that are required to avoid errors, i.e. padding and default precision and scale.
-  private final static boolean SUCCEED_WITHOUT_EXTRA_ARGS = false;
-  private final static boolean FAIL_WITHOUT_EXTRA_ARGS = true;
+  protected final static boolean SUCCEED_WITHOUT_EXTRA_ARGS = false;
+  protected final static boolean FAIL_WITHOUT_EXTRA_ARGS = true;
 
   // Constants for the test case that has padding specified but not default precision and scale.
-  private final static boolean SUCCEED_WITH_PADDING_ONLY = false;
-  private final static boolean FAIL_WITH_PADDING_ONLY = true;
-  private Path tableDirPath;
+  protected final static boolean SUCCEED_WITH_PADDING_ONLY = false;
+  protected final static boolean FAIL_WITH_PADDING_ONLY = true;
 
-  @Parameters(name = "Adapter: {0}| Config: {1}| failWithoutExtraArgs: {2}| failWithPadding: {3}")
-  public static Iterable<? extends Object> testConfigurations() {
-    DatabaseAdapter postgresAdapter = new PostgresDatabaseAdapter();
-    OracleDatabaseAdapter oracleDatabaseAdapter = new OracleDatabaseAdapter();
-    return Arrays.asList(
-        new Object[] {oracleDatabaseAdapter, new OracleImportJobTestConfigurationForNumber(), FAIL_WITHOUT_EXTRA_ARGS, FAIL_WITH_PADDING_ONLY},
-        new Object[] {oracleDatabaseAdapter, new OracleImportJobTestConfiguration(), FAIL_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY},
-        new Object[] { new MySqlDatabaseAdapter(), new MySQLImportJobTestConfiguration(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY},
-        new Object[] { new MSSQLServerDatabaseAdapter(), new MSSQLServerImportJobTestConfiguration(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY},
-        new Object[] { postgresAdapter, new PostgresqlImportJobTestConfigurationForNumeric(), FAIL_WITHOUT_EXTRA_ARGS, FAIL_WITH_PADDING_ONLY},
-        new Object[] { postgresAdapter, new PostgresqlImportJobTestConfigurationPaddingShouldSucceed(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY}
-    );
-  }
+  private Path tableDirPath;
 
-  public NumericTypesImportTest(DatabaseAdapter adapter, T configuration, boolean failWithoutExtraArgs, boolean failWithPaddingOnly) {
-    this.adapter = adapter;
+  public NumericTypesImportTestBase(T configuration, boolean failWithoutExtraArgs, boolean failWithPaddingOnly) {
+    this.adapter = createAdapter();
     this.configuration = configuration;
     this.failWithoutExtraArgs = failWithoutExtraArgs;
     this.failWithPadding = failWithPaddingOnly;
diff --git a/src/test/org/apache/sqoop/importjob/numerictypes/OracleNumericTypesImportTest.java b/src/test/org/apache/sqoop/importjob/numerictypes/OracleNumericTypesImportTest.java
new file mode 100644 (file)
index 0000000..292884b
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * 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.importjob.numerictypes;
+
+import org.apache.sqoop.importjob.configuration.AvroTestConfiguration;
+import org.apache.sqoop.importjob.configuration.OracleImportJobTestConfiguration;
+import org.apache.sqoop.importjob.configuration.OracleImportJobTestConfigurationForNumber;
+import org.apache.sqoop.importjob.configuration.ParquetTestConfiguration;
+import org.apache.sqoop.testcategories.thirdpartytest.OracleTest;
+import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
+import org.apache.sqoop.testutil.adapter.OracleDatabaseAdapter;
+import org.apache.sqoop.util.BlockJUnit4ClassRunnerWithParametersFactory;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+
+@Category(OracleTest.class)
+@RunWith(Parameterized.class)
+@Parameterized.UseParametersRunnerFactory(BlockJUnit4ClassRunnerWithParametersFactory.class)
+public class OracleNumericTypesImportTest<T extends AvroTestConfiguration & ParquetTestConfiguration> extends NumericTypesImportTestBase<T> {
+
+  @Override
+  public DatabaseAdapter createAdapter() {
+    return new OracleDatabaseAdapter();
+  }
+
+  @Parameterized.Parameters(name = "Config: {0}| failWithoutExtraArgs: {1}| failWithPadding: {2}")
+  public static Iterable<? extends Object> testConfigurations() {
+    return Arrays.asList(
+        new Object[]{new OracleImportJobTestConfigurationForNumber(), FAIL_WITHOUT_EXTRA_ARGS, FAIL_WITH_PADDING_ONLY},
+        new Object[]{new OracleImportJobTestConfiguration(), FAIL_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY}
+    );
+  }
+
+  public OracleNumericTypesImportTest(T configuration, boolean failWithoutExtraArgs, boolean failWithPaddingOnly) {
+    super(configuration, failWithoutExtraArgs, failWithPaddingOnly);
+  }
+}
diff --git a/src/test/org/apache/sqoop/importjob/numerictypes/PostgresNumericTypesImportTest.java b/src/test/org/apache/sqoop/importjob/numerictypes/PostgresNumericTypesImportTest.java
new file mode 100644 (file)
index 0000000..003b27d
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * 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.importjob.numerictypes;
+
+import org.apache.sqoop.importjob.configuration.AvroTestConfiguration;
+import org.apache.sqoop.importjob.configuration.ParquetTestConfiguration;
+import org.apache.sqoop.importjob.configuration.PostgresqlImportJobTestConfigurationForNumeric;
+import org.apache.sqoop.importjob.configuration.PostgresqlImportJobTestConfigurationPaddingShouldSucceed;
+import org.apache.sqoop.testcategories.thirdpartytest.PostgresqlTest;
+import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
+import org.apache.sqoop.testutil.adapter.PostgresDatabaseAdapter;
+import org.apache.sqoop.util.BlockJUnit4ClassRunnerWithParametersFactory;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+
+@Category(PostgresqlTest.class)
+@RunWith(Parameterized.class)
+@Parameterized.UseParametersRunnerFactory(BlockJUnit4ClassRunnerWithParametersFactory.class)
+public class PostgresNumericTypesImportTest<T extends AvroTestConfiguration & ParquetTestConfiguration> extends NumericTypesImportTestBase<T> {
+
+  @Override
+  public DatabaseAdapter createAdapter() {
+    return new PostgresDatabaseAdapter();
+  }
+
+  @Parameterized.Parameters(name = "Config: {0}| failWithoutExtraArgs: {1}| failWithPadding: {2}")
+  public static Iterable<? extends Object> testConfigurations() {
+    return Arrays.asList(
+        new Object[]{new PostgresqlImportJobTestConfigurationForNumeric(), FAIL_WITHOUT_EXTRA_ARGS, FAIL_WITH_PADDING_ONLY},
+        new Object[]{new PostgresqlImportJobTestConfigurationPaddingShouldSucceed(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY}
+    );
+  }
+
+  public PostgresNumericTypesImportTest(T configuration, boolean failWithoutExtraArgs, boolean failWithPaddingOnly) {
+    super(configuration, failWithoutExtraArgs, failWithPaddingOnly);
+  }
+}
diff --git a/src/test/org/apache/sqoop/importjob/numerictypes/SqlServerNumericTypesImportTest.java b/src/test/org/apache/sqoop/importjob/numerictypes/SqlServerNumericTypesImportTest.java
new file mode 100644 (file)
index 0000000..17b94c5
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * 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.importjob.numerictypes;
+
+import org.apache.sqoop.importjob.configuration.SqlServerImportJobTestConfiguration;
+import org.apache.sqoop.testcategories.thirdpartytest.SqlServerTest;
+import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
+import org.apache.sqoop.testutil.adapter.SqlServerDatabaseAdapter;
+import org.junit.experimental.categories.Category;
+
+@Category(SqlServerTest.class)
+public class SqlServerNumericTypesImportTest extends NumericTypesImportTestBase {
+
+  @Override
+  public DatabaseAdapter createAdapter() {
+    return new SqlServerDatabaseAdapter();
+  }
+
+  public SqlServerNumericTypesImportTest() {
+    super(new SqlServerImportJobTestConfiguration(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY);
+  }
+}
diff --git a/src/test/org/apache/sqoop/importjob/splitby/MysqlSplitByImportTest.java b/src/test/org/apache/sqoop/importjob/splitby/MysqlSplitByImportTest.java
new file mode 100644 (file)
index 0000000..daba08b
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * 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.importjob.splitby;
+
+import org.apache.sqoop.testcategories.thirdpartytest.MysqlTest;
+import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
+import org.apache.sqoop.testutil.adapter.MysqlDatabaseAdapter;
+import org.junit.experimental.categories.Category;
+
+@Category(MysqlTest.class)
+public class MysqlSplitByImportTest extends SplitByImportTestBase {
+
+  @Override
+  public DatabaseAdapter createAdapter() {
+    return new MysqlDatabaseAdapter();
+  }
+}
diff --git a/src/test/org/apache/sqoop/importjob/splitby/OracleSplitByImportTest.java b/src/test/org/apache/sqoop/importjob/splitby/OracleSplitByImportTest.java
new file mode 100644 (file)
index 0000000..dff2800
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * 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.importjob.splitby;
+
+import org.apache.sqoop.testcategories.thirdpartytest.OracleTest;
+import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
+import org.apache.sqoop.testutil.adapter.OracleDatabaseAdapter;
+import org.junit.experimental.categories.Category;
+
+@Category(OracleTest.class)
+public class OracleSplitByImportTest extends SplitByImportTestBase {
+
+  @Override
+  public DatabaseAdapter createAdapter() {
+    return new OracleDatabaseAdapter();
+  }
+}
diff --git a/src/test/org/apache/sqoop/importjob/splitby/PostgresSplitByImportTest.java b/src/test/org/apache/sqoop/importjob/splitby/PostgresSplitByImportTest.java
new file mode 100644 (file)
index 0000000..369770c
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * 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.importjob.splitby;
+
+import org.apache.sqoop.testcategories.thirdpartytest.PostgresqlTest;
+import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
+import org.apache.sqoop.testutil.adapter.PostgresDatabaseAdapter;
+import org.junit.experimental.categories.Category;
+
+@Category(PostgresqlTest.class)
+public class PostgresSplitByImportTest extends SplitByImportTestBase {
+
+  @Override
+  public DatabaseAdapter createAdapter() {
+    return new PostgresDatabaseAdapter();
+  }
+}
  * limitations under the License.
  */
 
-package org.apache.sqoop.importjob;
+package org.apache.sqoop.importjob.splitby;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.sqoop.SqoopOptions;
+import org.apache.sqoop.importjob.DatabaseAdapterFactory;
 import org.apache.sqoop.importjob.configuration.GenericImportJobSplitByTestConfiguration;
-import org.apache.sqoop.testcategories.thirdpartytest.ThirdPartyTest;
-import org.apache.sqoop.importjob.configuration.ImportJobTestConfiguration;
 import org.apache.sqoop.importjob.configuration.ParquetTestConfiguration;
 import org.apache.sqoop.testutil.ArgumentArrayBuilder;
 import org.apache.sqoop.testutil.ImportJobTestCase;
 import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
-import org.apache.sqoop.testutil.adapter.MSSQLServerDatabaseAdapter;
-import org.apache.sqoop.testutil.adapter.MySqlDatabaseAdapter;
-import org.apache.sqoop.testutil.adapter.OracleDatabaseAdapter;
-import org.apache.sqoop.testutil.adapter.PostgresDatabaseAdapter;
-import org.apache.sqoop.util.BlockJUnit4ClassRunnerWithParametersFactory;
 import org.apache.sqoop.util.ParquetReader;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.experimental.categories.Category;
 import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
 
 import java.io.IOException;
 import java.sql.SQLException;
@@ -53,32 +43,18 @@ import java.util.List;
 import static java.util.Arrays.asList;
 import static org.junit.Assert.assertEquals;
 
-@RunWith(Parameterized.class)
-@Category(ThirdPartyTest.class)
-@Parameterized.UseParametersRunnerFactory(BlockJUnit4ClassRunnerWithParametersFactory.class)
-public class SplitByImportTest extends ImportJobTestCase {
+public abstract class SplitByImportTestBase extends ImportJobTestCase implements DatabaseAdapterFactory {
 
-  public static final Log LOG = LogFactory.getLog(SplitByImportTest.class.getName());
+  public static final Log LOG = LogFactory.getLog(SplitByImportTestBase.class.getName());
 
   private Configuration conf = new Configuration();
 
   private final ParquetTestConfiguration configuration;
   private final DatabaseAdapter adapter;
 
-  @Parameters(name = "Adapter: {0}| Config: {1}")
-  public static Iterable<? extends Object> testConfigurations() {
-    GenericImportJobSplitByTestConfiguration testConfiguration = new GenericImportJobSplitByTestConfiguration();
-    return asList(
-        new Object[] {new OracleDatabaseAdapter(), testConfiguration},
-        new Object[] {new PostgresDatabaseAdapter(), testConfiguration},
-        new Object[] {new MSSQLServerDatabaseAdapter(), testConfiguration},
-        new Object[] {new MySqlDatabaseAdapter(), testConfiguration}
-    );
-  }
-
-  public SplitByImportTest(DatabaseAdapter adapter, ParquetTestConfiguration configuration) {
-    this.adapter = adapter;
-    this.configuration = configuration;
+  public SplitByImportTestBase() {
+    this.adapter = createAdapter();
+    this.configuration =  new GenericImportJobSplitByTestConfiguration();
   }
 
   @Rule
diff --git a/src/test/org/apache/sqoop/importjob/splitby/SqlServerSplitByImportTest.java b/src/test/org/apache/sqoop/importjob/splitby/SqlServerSplitByImportTest.java
new file mode 100644 (file)
index 0000000..c1e9c88
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * 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.importjob.splitby;
+
+import org.apache.sqoop.testcategories.thirdpartytest.SqlServerTest;
+import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
+import org.apache.sqoop.testutil.adapter.SqlServerDatabaseAdapter;
+import org.junit.experimental.categories.Category;
+
+@Category(SqlServerTest.class)
+public class SqlServerSplitByImportTest extends SplitByImportTestBase {
+
+  @Override
+  public DatabaseAdapter createAdapter() {
+    return new SqlServerDatabaseAdapter();
+  }
+}
@@ -24,7 +24,7 @@ import org.apache.sqoop.manager.mysql.MySQLTestUtils;
 
 import java.sql.SQLException;
 
-public class MySqlDatabaseAdapter implements DatabaseAdapter {
+public class MysqlDatabaseAdapter implements DatabaseAdapter {
   private MySQLTestUtils mySQLTestUtils = new MySQLTestUtils();
 
   public SqoopOptions injectConnectionParameters(SqoopOptions options) {
@@ -24,7 +24,7 @@ import org.apache.sqoop.manager.sqlserver.MSSQLTestUtils;
 
 import java.sql.SQLException;
 
-public class MSSQLServerDatabaseAdapter implements DatabaseAdapter {
+public class SqlServerDatabaseAdapter implements DatabaseAdapter {
 
   @Override
   public String getConnectionString() {