mirror of
https://github.com/apache/sqoop.git
synced 2025-05-16 00:41:23 +08:00
SQOOP-2625: Sqoop2: Fix test case failure for repository-mysql
(Colin Ma via Jarek Jarcec Cecho)
This commit is contained in:
parent
b09b897cf8
commit
ecdb8167b4
@ -34,7 +34,7 @@ public class MySQLProvider extends DatabaseProvider {
|
||||
|
||||
private static final String CONNECTION = System.getProperties().getProperty(
|
||||
"sqoop.provider.mysql.jdbc",
|
||||
"jdbc:mysql://localhost/test"
|
||||
"jdbc:mysql://localhost:3306/test?createDatabaseIfNotExist=true&sessionVariables=sql_mode='ANSI_QUOTES'"
|
||||
);
|
||||
|
||||
private static final String USERNAME = System.getProperties().getProperty(
|
||||
|
@ -61,6 +61,11 @@ limitations under the License.
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -106,7 +111,6 @@ limitations under the License.
|
||||
<name>mysql</name>
|
||||
</property>
|
||||
</activation>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -22,11 +22,9 @@
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.sqoop.common.test.db.DatabaseProvider;
|
||||
import org.apache.sqoop.common.test.db.MySQLProvider;
|
||||
import org.apache.sqoop.connector.ConnectorManager;
|
||||
import org.apache.sqoop.json.DriverBean;
|
||||
import org.apache.sqoop.model.InputEditable;
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
@ -47,23 +45,27 @@
|
||||
import org.apache.sqoop.submission.SubmissionStatus;
|
||||
import org.apache.sqoop.submission.counter.CounterGroup;
|
||||
import org.apache.sqoop.submission.counter.Counters;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.*;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
/**
|
||||
* Abstract class with convenience methods for testing mysql repository.
|
||||
*/
|
||||
abstract public class MySqlTestCase extends TestCase {
|
||||
|
||||
public static DatabaseProvider provider;
|
||||
abstract public class MySqlTestCase {
|
||||
public static MySQLProvider provider;
|
||||
public static MySqlTestUtils utils;
|
||||
public MySqlRepositoryHandler handler;
|
||||
private ConnectorManager mockConnectorManager;
|
||||
|
||||
@BeforeClass
|
||||
public void setUpClass() {
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setUpClass() throws Exception {
|
||||
provider = new MySQLProvider();
|
||||
utils = new MySqlTestUtils(provider);
|
||||
|
||||
mockConnectorManager = Mockito.mock(ConnectorManager.class);
|
||||
Mockito.when(mockConnectorManager.getConnectorConfigurable("A")).thenReturn(getConnector(true, true, "A", "org.apache.sqoop.test.A"));
|
||||
Mockito.when(mockConnectorManager.getConnectorConfigurable("B")).thenReturn(getConnector(true, true, "B", "org.apache.sqoop.test.B"));
|
||||
ConnectorManager.setInstance(mockConnectorManager);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
@ -77,7 +79,7 @@ public void setUp() throws Exception {
|
||||
|
||||
@AfterMethod(alwaysRun = true)
|
||||
public void tearDown() throws Exception {
|
||||
provider.dropDatabase("SQOOP");
|
||||
provider.dropDatabase(CommonRepositorySchemaConstants.SCHEMA_SQOOP);
|
||||
provider.stop();
|
||||
}
|
||||
|
||||
@ -184,4 +186,17 @@ protected List<MConfig> getConfigs(String configName1, String configName2) {
|
||||
|
||||
return configs;
|
||||
}
|
||||
|
||||
protected MConnector getConnector(boolean from, boolean to, String connectorName, String connectorClass) {
|
||||
MFromConfig fromConfig = null;
|
||||
MToConfig toConfig = null;
|
||||
if (from) {
|
||||
fromConfig = getFromConfig();
|
||||
}
|
||||
if (to) {
|
||||
toConfig = getToConfig();
|
||||
}
|
||||
return new MConnector(connectorName, connectorClass, "1.0-test", getLinkConfig(), fromConfig,
|
||||
toConfig);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,10 @@
|
||||
import org.apache.sqoop.model.MConnector;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Test driver methods on MySql repository.
|
||||
*/
|
||||
|
@ -22,6 +22,10 @@
|
||||
import org.apache.sqoop.model.MDriver;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Test driver methods on MySql repository.
|
||||
*/
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test driver methods on MySql repository.
|
||||
*/
|
||||
|
@ -35,6 +35,12 @@
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test driver methods on MySql repository.
|
||||
*/
|
||||
|
@ -33,6 +33,12 @@
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test driver methods on MySql repository.
|
||||
*/
|
||||
|
@ -36,6 +36,11 @@
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test driver methods on MySql repository.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user