From 0a7407613b12a4bb25e737506ef0f091d3a7dae1 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 22 Nov 2018 05:43:21 -0800 Subject: [PATCH] SQOOP-3405: Refactor: break up Parameterized tests on a per database basis (Fero Szabo via Szabolcs Vasas) --- .../importjob/DatabaseAdapterFactory.java | 26 +++++++++ ...a => MysqlImportJobTestConfiguration.java} | 2 +- ... SqlServerImportJobTestConfiguration.java} | 2 +- .../MysqlNumericTypesImportTest.java | 38 +++++++++++++ .../NumericTypesImportTestBase.java} | 52 ++++------------- .../OracleNumericTypesImportTest.java | 56 +++++++++++++++++++ .../PostgresNumericTypesImportTest.java | 56 +++++++++++++++++++ .../SqlServerNumericTypesImportTest.java | 38 +++++++++++++ .../splitby/MysqlSplitByImportTest.java | 33 +++++++++++ .../splitby/OracleSplitByImportTest.java | 33 +++++++++++ .../splitby/PostgresSplitByImportTest.java | 33 +++++++++++ .../SplitByImportTestBase.java} | 38 +++---------- .../splitby/SqlServerSplitByImportTest.java | 33 +++++++++++ ...Adapter.java => MysqlDatabaseAdapter.java} | 2 +- ...ter.java => SqlServerDatabaseAdapter.java} | 2 +- 15 files changed, 369 insertions(+), 75 deletions(-) create mode 100644 src/test/org/apache/sqoop/importjob/DatabaseAdapterFactory.java rename src/test/org/apache/sqoop/importjob/configuration/{MySQLImportJobTestConfiguration.java => MysqlImportJobTestConfiguration.java} (97%) rename src/test/org/apache/sqoop/importjob/configuration/{MSSQLServerImportJobTestConfiguration.java => SqlServerImportJobTestConfiguration.java} (94%) create mode 100644 src/test/org/apache/sqoop/importjob/numerictypes/MysqlNumericTypesImportTest.java rename src/test/org/apache/sqoop/importjob/{NumericTypesImportTest.java => numerictypes/NumericTypesImportTestBase.java} (76%) create mode 100644 src/test/org/apache/sqoop/importjob/numerictypes/OracleNumericTypesImportTest.java create mode 100644 src/test/org/apache/sqoop/importjob/numerictypes/PostgresNumericTypesImportTest.java create mode 100644 src/test/org/apache/sqoop/importjob/numerictypes/SqlServerNumericTypesImportTest.java create mode 100644 src/test/org/apache/sqoop/importjob/splitby/MysqlSplitByImportTest.java create mode 100644 src/test/org/apache/sqoop/importjob/splitby/OracleSplitByImportTest.java create mode 100644 src/test/org/apache/sqoop/importjob/splitby/PostgresSplitByImportTest.java rename src/test/org/apache/sqoop/importjob/{SplitByImportTest.java => splitby/SplitByImportTestBase.java} (71%) create mode 100644 src/test/org/apache/sqoop/importjob/splitby/SqlServerSplitByImportTest.java rename src/test/org/apache/sqoop/testutil/adapter/{MySqlDatabaseAdapter.java => MysqlDatabaseAdapter.java} (96%) rename src/test/org/apache/sqoop/testutil/adapter/{MSSQLServerDatabaseAdapter.java => SqlServerDatabaseAdapter.java} (96%) diff --git a/src/test/org/apache/sqoop/importjob/DatabaseAdapterFactory.java b/src/test/org/apache/sqoop/importjob/DatabaseAdapterFactory.java new file mode 100644 index 00000000..0e9cdc31 --- /dev/null +++ b/src/test/org/apache/sqoop/importjob/DatabaseAdapterFactory.java @@ -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(); +} diff --git a/src/test/org/apache/sqoop/importjob/configuration/MySQLImportJobTestConfiguration.java b/src/test/org/apache/sqoop/importjob/configuration/MysqlImportJobTestConfiguration.java similarity index 97% rename from src/test/org/apache/sqoop/importjob/configuration/MySQLImportJobTestConfiguration.java rename to src/test/org/apache/sqoop/importjob/configuration/MysqlImportJobTestConfiguration.java index fbcbdebe..49365043 100644 --- a/src/test/org/apache/sqoop/importjob/configuration/MySQLImportJobTestConfiguration.java +++ b/src/test/org/apache/sqoop/importjob/configuration/MysqlImportJobTestConfiguration.java @@ -21,7 +21,7 @@ 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() { diff --git a/src/test/org/apache/sqoop/importjob/configuration/MSSQLServerImportJobTestConfiguration.java b/src/test/org/apache/sqoop/importjob/configuration/SqlServerImportJobTestConfiguration.java similarity index 94% rename from src/test/org/apache/sqoop/importjob/configuration/MSSQLServerImportJobTestConfiguration.java rename to src/test/org/apache/sqoop/importjob/configuration/SqlServerImportJobTestConfiguration.java index 4ad7defe..aacbabfd 100644 --- a/src/test/org/apache/sqoop/importjob/configuration/MSSQLServerImportJobTestConfiguration.java +++ b/src/test/org/apache/sqoop/importjob/configuration/SqlServerImportJobTestConfiguration.java @@ -21,7 +21,7 @@ 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 index 00000000..e39be382 --- /dev/null +++ b/src/test/org/apache/sqoop/importjob/numerictypes/MysqlNumericTypesImportTest.java @@ -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); + } +} diff --git a/src/test/org/apache/sqoop/importjob/NumericTypesImportTest.java b/src/test/org/apache/sqoop/importjob/numerictypes/NumericTypesImportTestBase.java similarity index 76% rename from src/test/org/apache/sqoop/importjob/NumericTypesImportTest.java rename to src/test/org/apache/sqoop/importjob/numerictypes/NumericTypesImportTestBase.java index af310cbe..320adb3a 100644 --- a/src/test/org/apache/sqoop/importjob/NumericTypesImportTest.java +++ b/src/test/org/apache/sqoop/importjob/numerictypes/NumericTypesImportTestBase.java @@ -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.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 @@ * 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 extends ImportJobTestCase { +public abstract class NumericTypesImportTestBase 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 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} - ); - } - - 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 index 00000000..292884bd --- /dev/null +++ b/src/test/org/apache/sqoop/importjob/numerictypes/OracleNumericTypesImportTest.java @@ -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 extends NumericTypesImportTestBase { + + @Override + public DatabaseAdapter createAdapter() { + return new OracleDatabaseAdapter(); + } + + @Parameterized.Parameters(name = "Config: {0}| failWithoutExtraArgs: {1}| failWithPadding: {2}") + public static Iterable 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 index 00000000..003b27d0 --- /dev/null +++ b/src/test/org/apache/sqoop/importjob/numerictypes/PostgresNumericTypesImportTest.java @@ -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 extends NumericTypesImportTestBase { + + @Override + public DatabaseAdapter createAdapter() { + return new PostgresDatabaseAdapter(); + } + + @Parameterized.Parameters(name = "Config: {0}| failWithoutExtraArgs: {1}| failWithPadding: {2}") + public static Iterable 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 index 00000000..17b94c51 --- /dev/null +++ b/src/test/org/apache/sqoop/importjob/numerictypes/SqlServerNumericTypesImportTest.java @@ -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 index 00000000..daba08b6 --- /dev/null +++ b/src/test/org/apache/sqoop/importjob/splitby/MysqlSplitByImportTest.java @@ -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 index 00000000..dff2800b --- /dev/null +++ b/src/test/org/apache/sqoop/importjob/splitby/OracleSplitByImportTest.java @@ -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 index 00000000..369770c4 --- /dev/null +++ b/src/test/org/apache/sqoop/importjob/splitby/PostgresSplitByImportTest.java @@ -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(); + } +} diff --git a/src/test/org/apache/sqoop/importjob/SplitByImportTest.java b/src/test/org/apache/sqoop/importjob/splitby/SplitByImportTestBase.java similarity index 71% rename from src/test/org/apache/sqoop/importjob/SplitByImportTest.java rename to src/test/org/apache/sqoop/importjob/splitby/SplitByImportTestBase.java index 90b7cbbd..2fc6b95f 100644 --- a/src/test/org/apache/sqoop/importjob/SplitByImportTest.java +++ b/src/test/org/apache/sqoop/importjob/splitby/SplitByImportTestBase.java @@ -16,35 +16,25 @@ * 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 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 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 index 00000000..c1e9c881 --- /dev/null +++ b/src/test/org/apache/sqoop/importjob/splitby/SqlServerSplitByImportTest.java @@ -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(); + } +} diff --git a/src/test/org/apache/sqoop/testutil/adapter/MySqlDatabaseAdapter.java b/src/test/org/apache/sqoop/testutil/adapter/MysqlDatabaseAdapter.java similarity index 96% rename from src/test/org/apache/sqoop/testutil/adapter/MySqlDatabaseAdapter.java rename to src/test/org/apache/sqoop/testutil/adapter/MysqlDatabaseAdapter.java index ebd01468..ff2466c6 100644 --- a/src/test/org/apache/sqoop/testutil/adapter/MySqlDatabaseAdapter.java +++ b/src/test/org/apache/sqoop/testutil/adapter/MysqlDatabaseAdapter.java @@ -24,7 +24,7 @@ import java.sql.SQLException; -public class MySqlDatabaseAdapter implements DatabaseAdapter { +public class MysqlDatabaseAdapter implements DatabaseAdapter { private MySQLTestUtils mySQLTestUtils = new MySQLTestUtils(); public SqoopOptions injectConnectionParameters(SqoopOptions options) { diff --git a/src/test/org/apache/sqoop/testutil/adapter/MSSQLServerDatabaseAdapter.java b/src/test/org/apache/sqoop/testutil/adapter/SqlServerDatabaseAdapter.java similarity index 96% rename from src/test/org/apache/sqoop/testutil/adapter/MSSQLServerDatabaseAdapter.java rename to src/test/org/apache/sqoop/testutil/adapter/SqlServerDatabaseAdapter.java index 22567162..c675adb5 100644 --- a/src/test/org/apache/sqoop/testutil/adapter/MSSQLServerDatabaseAdapter.java +++ b/src/test/org/apache/sqoop/testutil/adapter/SqlServerDatabaseAdapter.java @@ -24,7 +24,7 @@ import java.sql.SQLException; -public class MSSQLServerDatabaseAdapter implements DatabaseAdapter { +public class SqlServerDatabaseAdapter implements DatabaseAdapter { @Override public String getConnectionString() {