You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ab...@apache.org on 2014/10/03 08:53:20 UTC
[06/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
----------------------------------------------------------------------
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 19b0023..e6e4760 100644
--- a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
+++ b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
@@ -17,6 +17,23 @@
*/
package org.apache.sqoop.repository;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+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 java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,40 +46,27 @@ import org.apache.sqoop.connector.ConnectorManager;
import org.apache.sqoop.connector.spi.RepositoryUpgrader;
import org.apache.sqoop.connector.spi.SqoopConnector;
import org.apache.sqoop.driver.Driver;
-import org.apache.sqoop.driver.configuration.JobConfiguration;
+import org.apache.sqoop.driver.configuration.DriverConfiguration;
+import org.apache.sqoop.json.DriverBean;
+import org.apache.sqoop.model.ConfigUtils;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.FormUtils;
-import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MConfigList;
import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.model.MForm;
+import org.apache.sqoop.model.MFromConfig;
import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MJobForms;
import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MLinkConfig;
+import org.apache.sqoop.model.MToConfig;
+import org.apache.sqoop.validation.ConfigValidator;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
import org.apache.sqoop.validation.Validator;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
public class TestJdbcRepository {
private JdbcRepository repoSpy;
@@ -73,8 +77,8 @@ public class TestJdbcRepository {
private Validator validatorMock;
private RepositoryUpgrader upgraderMock;
- private Validation validRepoMock;
- private Validation invalidRepoMock;
+ private ConfigValidator validRepoMock;
+ private ConfigValidator invalidRepoMock;
@Before
public void setUp() throws Exception {
@@ -91,20 +95,20 @@ public class TestJdbcRepository {
ConnectorManager.setInstance(connectorMgrMock);
Driver.setInstance(driverMock);
- validRepoMock = mock(Validation.class);
+ validRepoMock = mock(ConfigValidator.class);
when(validRepoMock.getStatus()).thenReturn(Status.ACCEPTABLE);
- invalidRepoMock = mock(Validation.class);
+ invalidRepoMock = mock(ConfigValidator.class);
when(invalidRepoMock.getStatus()).thenReturn(Status.UNACCEPTABLE);
- doNothing().when(upgraderMock).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
- doNothing().when(upgraderMock).upgrade(any(MJobForms.class), any(MJobForms.class));
+ doNothing().when(upgraderMock).upgrade(any(MLinkConfig.class), any(MLinkConfig.class));
+ doNothing().when(upgraderMock).upgrade(any(MFromConfig.class), any(MFromConfig.class));
}
/**
* Test the procedure when the connector auto upgrade option is enabled
*/
@Test
- public void testConnectorEnableAutoUpgrade() {
+ public void testConnectorConfigEnableAutoUpgrade() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1, "1.0");
@@ -155,22 +159,22 @@ public class TestJdbcRepository {
*/
@Test
public void testDriverConfigEnableAutoUpgrade() {
- MDriverConfig newDriverConfig = driverConfig();
- MDriverConfig oldDriverConfig = anotherDriverConfig();
+ MDriver newDriverConfig = driver();
+ MDriver oldDriverConfig = anotherDriver();
- when(repoHandlerMock.findDriverConfig(any(Connection.class))).thenReturn(oldDriverConfig);
+ when(repoHandlerMock.findDriver(any(Connection.class))).thenReturn(oldDriverConfig);
// make the upgradeDriverConfig to throw an exception to prove that it has been called
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"upgradeDriverConfig() has been called.");
- doThrow(exception).when(repoHandlerMock).findLinks(any(Connection.class));
+ doThrow(exception).when(repoHandlerMock).findJobs(any(Connection.class));
try {
- repoSpy.registerDriverConfig(newDriverConfig, true);
+ repoSpy.registerDriver(newDriverConfig, true);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findDriverConfig(any(Connection.class));
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
+ verify(repoHandlerMock, times(1)).findDriver(any(Connection.class));
+ verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -183,16 +187,16 @@ public class TestJdbcRepository {
*/
@Test
public void testDriverConfigDisableAutoUpgrade() {
- MDriverConfig newDriverConfig = driverConfig();
- MDriverConfig oldDriverConfig = anotherDriverConfig();
+ MDriver newDriverConfig = driver();
+ MDriver oldDriverConfig = anotherDriver();
- when(repoHandlerMock.findDriverConfig(any(Connection.class))).thenReturn(oldDriverConfig);
+ when(repoHandlerMock.findDriver(any(Connection.class))).thenReturn(oldDriverConfig);
try {
- repoSpy.registerDriverConfig(newDriverConfig, false);
+ repoSpy.registerDriver(newDriverConfig, false);
} catch (SqoopException ex) {
assertEquals(ex.getErrorCode(), RepositoryError.JDBCREPO_0026);
- verify(repoHandlerMock, times(1)).findDriverConfig(any(Connection.class));
+ verify(repoHandlerMock, times(1)).findDriver(any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -205,18 +209,18 @@ public class TestJdbcRepository {
* jobs using the old connector are still valid for the new connector
*/
@Test
- public void testConnectorUpgradeWithValidLinksAndJobs() {
+ public void testConnectorConfigUpgradeWithValidLinksAndJobs() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
// prepare the sqoop connector
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
- when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(JobConfiguration.class);
+ when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationGroup.class);
+ when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(DriverConfiguration.class);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
// prepare the links and jobs
@@ -252,160 +256,82 @@ public class TestJdbcRepository {
txOrder.verify(repoTransactionMock, times(1)).commit();
txOrder.verify(repoTransactionMock, times(1)).close();
txOrder.verifyNoMoreInteractions();
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
- upgraderOrder.verify(upgraderMock, times(4)).upgrade(any(MJobForms.class), any(MJobForms.class));
+ upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MLinkConfig.class), any(MLinkConfig.class));
+ upgraderOrder.verify(upgraderMock, times(4)).upgrade(any(MFromConfig.class), any(MFromConfig.class));
upgraderOrder.verifyNoMoreInteractions();
- validatorOrder.verify(validatorMock, times(2)).validateLink(anyObject());
+ validatorOrder.verify(validatorMock, times(2)).validateConfigForLink(anyObject());
// @TODO(Abe): Re-enable job validation?
- validatorOrder.verify(validatorMock, times(0)).validateJob(anyObject());
+ validatorOrder.verify(validatorMock, times(0)).validateConfigForJob(anyObject());
validatorOrder.verifyNoMoreInteractions();
}
/**
- * @TODO(Abe): To re-enable with Validation in Repository upgrade.
- * Test the connector upgrade procedure, when all the links and
- * jobs using the old connector are invalid for the new connector
- */
-// @Test
-// public void testConnectorUpgradeWithInvalidLinksAndJobs() {
-// MConnector newConnector = connector(1, "1.1");
-// MConnector oldConnector = connector(1);
-//
-// // prepare the sqoop connector
-// SqoopConnector sqconnector = mock(SqoopConnector.class);
-// when(validator.validateLink(any(MLink.class))).thenReturn(invalid);
-// when(validator.validateJob(any(MJob.class))).thenReturn(invalid);
-// when(sqconnector.getValidator()).thenReturn(validator);
-// when(sqconnector.getDriverConfigRepositoryUpgrader()).thenReturn(upgrader);
-// when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
-// when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(JobConfiguration.class);
-// when(connectorMgr.getConnector(anyString())).thenReturn(sqconnector);
-//
-// // prepare the links and jobs
-// List<MLink> linkList = links(link(1,1), link(2,1));
-// List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
-//
-// doReturn(linkList).when(repo).findLinksForConnector(anyLong());
-// doReturn(jobList).when(repo).findJobsForConnector(anyLong());
-// doNothing().when(repo).updateLink(any(MLink.class), any(RepositoryTransaction.class));
-// doNothing().when(repo).updateJob(any(MJob.class), any(RepositoryTransaction.class));
-// doNothing().when(repo).updateConnector(any(MConnector.class), any(RepositoryTransaction.class));
-//
-// try {
-// repo.upgradeConnector(oldConnector, newConnector);
-// } catch (SqoopException ex) {
-// assertEquals(ex.getErrorCode(), RepositoryError.JDBCREPO_0027);
-//
-// InOrder repoOrder = inOrder(repo);
-// InOrder txOrder = inOrder(tx);
-// InOrder upgraderOrder = inOrder(upgrader);
-// InOrder validatorOrder = inOrder(validator);
-//
-// repoOrder.verify(repo, times(1)).findLinksForConnector(anyLong());
-// repoOrder.verify(repo, times(1)).findJobsForConnector(anyLong());
-// repoOrder.verify(repo, times(1)).getTransaction();
-// repoOrder.verify(repo, times(1)).deleteJobInputs(1, tx);
-// repoOrder.verify(repo, times(1)).deleteJobInputs(2, tx);
-// repoOrder.verify(repo, times(1)).deleteLinkInputs(1, tx);
-// repoOrder.verify(repo, times(1)).deleteLinkInputs(2, tx);
-// repoOrder.verify(repo, times(1)).updateConnector(any(MConnector.class), any(RepositoryTransaction.class));
-// repoOrder.verifyNoMoreInteractions();
-// txOrder.verify(tx, times(1)).begin();
-// txOrder.verify(tx, times(1)).rollback();
-// txOrder.verify(tx, times(1)).close();
-// txOrder.verifyNoMoreInteractions();
-// upgraderOrder.verify(upgrader, times(2)).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
-// upgraderOrder.verify(upgrader, times(2)).upgrade(any(MJobForms.class), any(MJobForms.class));
-// upgraderOrder.verifyNoMoreInteractions();
-// validatorOrder.verify(validator, times(2)).validateLink(anyObject());
-// validatorOrder.verify(validator, times(2)).validateJob(anyObject());
-// validatorOrder.verifyNoMoreInteractions();
-// return ;
-// }
-//
-// fail("Should throw out an exception with code: " + RepositoryError.JDBCREPO_0027);
-// }
-
- /**
- * Test the driverConfig upgrade procedure, when all the links and
- * jobs using the old connector are still valid for the new connector
+ * Test the driverConfig upgrade procedure, when all jobs
+ * using the old connector are still valid for the new connector
*/
@Test
- public void testDriverConfigUpgradeWithValidLinksAndJobs() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeWithValidJobs() {
+ MDriver newDriverConfig = driver();
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- when(driverMock.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(driverMock.getJobConfigurationClass()).thenReturn(JobConfiguration.class);
+ when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyConfigurationGroup.class);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoSpy).findLinks();
doReturn(jobList).when(repoSpy).findJobs();
doNothing().when(repoSpy).updateLink(any(MLink.class), any(RepositoryTransaction.class));
doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
- doNothing().when(repoSpy).updateDriverConfig(any(MDriverConfig.class), any(RepositoryTransaction.class));
+ doNothing().when(repoSpy).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
InOrder repoOrder = inOrder(repoSpy);
InOrder txOrder = inOrder(repoTransactionMock);
InOrder upgraderOrder = inOrder(upgraderMock);
InOrder validatorOrder = inOrder(validatorMock);
- repoOrder.verify(repoSpy, times(1)).findLinks();
repoOrder.verify(repoSpy, times(1)).findJobs();
repoOrder.verify(repoSpy, times(1)).getTransaction();
repoOrder.verify(repoSpy, times(1)).deleteJobInputs(1, repoTransactionMock);
repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(1, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(2, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).updateDriverConfig(any(MDriverConfig.class), any(RepositoryTransaction.class));
- repoOrder.verify(repoSpy, times(2)).updateLink(any(MLink.class), any(RepositoryTransaction.class));
+ repoOrder.verify(repoSpy, times(1)).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
repoOrder.verify(repoSpy, times(2)).updateJob(any(MJob.class), any(RepositoryTransaction.class));
repoOrder.verifyNoMoreInteractions();
txOrder.verify(repoTransactionMock, times(1)).begin();
txOrder.verify(repoTransactionMock, times(1)).commit();
txOrder.verify(repoTransactionMock, times(1)).close();
txOrder.verifyNoMoreInteractions();
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MJobForms.class), any(MJobForms.class));
+ upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConfigList.class), any(MConfigList.class));
upgraderOrder.verifyNoMoreInteractions();
- validatorOrder.verify(validatorMock, times(2)).validateLink(anyObject());
- validatorOrder.verify(validatorMock, times(2)).validateJob(anyObject());
+ validatorOrder.verify(validatorMock, times(2)).validateConfigForJob(anyObject());
validatorOrder.verifyNoMoreInteractions();
}
/**
- * Test the driverConfig upgrade procedure, when all the links and
- * jobs using the old connector are invalid for the new connector
+ * Test the driverConfig upgrade procedure, when all the jobs
+ * using the old connector are invalid for the new connector
*/
@Test
- public void testDriverConfigUpgradeWithInvalidLinksAndJobs() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeWithInvalidJobs() {
+ MDriver newDriverConfig = driver();
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(invalidRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(invalidRepoMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(invalidRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(invalidRepoMock);
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- when(driverMock.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(driverMock.getJobConfigurationClass()).thenReturn(JobConfiguration.class);
+ when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyConfigurationGroup.class);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoSpy).findLinks();
doReturn(jobList).when(repoSpy).findJobs();
- doNothing().when(repoSpy).updateLink(any(MLink.class), any(RepositoryTransaction.class));
doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
- doNothing().when(repoSpy).updateDriverConfig(any(MDriverConfig.class), any(RepositoryTransaction.class));
+ doNothing().when(repoSpy).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getErrorCode(), RepositoryError.JDBCREPO_0027);
@@ -414,24 +340,20 @@ public class TestJdbcRepository {
InOrder upgraderOrder = inOrder(upgraderMock);
InOrder validatorOrder = inOrder(validatorMock);
- repoOrder.verify(repoSpy, times(1)).findLinks();
repoOrder.verify(repoSpy, times(1)).findJobs();
repoOrder.verify(repoSpy, times(1)).getTransaction();
repoOrder.verify(repoSpy, times(1)).deleteJobInputs(1, repoTransactionMock);
repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(1, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(2, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).updateDriverConfig(any(MDriverConfig.class), any(RepositoryTransaction.class));
+ repoOrder.verify(repoSpy, times(1)).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
repoOrder.verifyNoMoreInteractions();
txOrder.verify(repoTransactionMock, times(1)).begin();
txOrder.verify(repoTransactionMock, times(1)).rollback();
txOrder.verify(repoTransactionMock, times(1)).close();
txOrder.verifyNoMoreInteractions();
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MJobForms.class), any(MJobForms.class));
+ upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConfigList.class), any(MConfigList.class));
upgraderOrder.verifyNoMoreInteractions();
- validatorOrder.verify(validatorMock, times(2)).validateLink(anyObject());
- validatorOrder.verify(validatorMock, times(2)).validateJob(anyObject());
+ // driver configs are per job.
+ validatorOrder.verify(validatorMock, times(2)).validateConfigForJob(anyObject());
validatorOrder.verifyNoMoreInteractions();
return ;
}
@@ -444,12 +366,12 @@ public class TestJdbcRepository {
* find links for a given connector
*/
@Test
- public void testConnectorUpgradeHandlerFindLinksForConnectorError() {
+ public void testConnectorConfigUpgradeHandlerWithFindLinksForConnectorError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -474,12 +396,12 @@ public class TestJdbcRepository {
* find jobs for a given connector
*/
@Test
- public void testConnectorUpgradeHandlerFindJobsForConnectorError() {
+ public void testConnectorConfigUpgradeHandlerWithFindJobsForConnectorError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -508,12 +430,12 @@ public class TestJdbcRepository {
* delete job inputs for a given connector
*/
@Test
- public void testConnectorUpgradeHandlerDeleteJobInputsError() {
+ public void testConnectorConfigUpgradeHandlerWithDeleteJobInputsError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -545,12 +467,12 @@ public class TestJdbcRepository {
* delete link inputs for a given connector
*/
@Test
- public void testConnectorUpgradeHandlerDeleteLinkInputsError() {
+ public void testConnectorConfigUpgradeHandlerWithDeleteLinkInputsError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -584,12 +506,12 @@ public class TestJdbcRepository {
* update the connector entity
*/
@Test
- public void testConnectorUpgradeHandlerUpdateConnectorError() {
+ public void testConnectorConfigUpgradeHandlerWithUpdateConnectorError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -625,17 +547,17 @@ public class TestJdbcRepository {
* update the link entity
*/
@Test
- public void testConnectorUpgradeHandlerUpdateLinkError() {
+ public void testConnectorConfigUpgradeHandlerWithUpdateLinkError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
- when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(JobConfiguration.class);
+ when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationGroup.class);
+ when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(DriverConfiguration.class);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
List<MLink> linkList = links(link(1,1), link(2,1));
@@ -674,17 +596,17 @@ public class TestJdbcRepository {
* update the job entity
*/
@Test
- public void testConnectorUpgradeHandlerUpdateJobError() {
+ public void testConnectorConfigUpgradeHandlerWithUpdateJobError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
- when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(JobConfiguration.class);
+ when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationGroup.class);
+ when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(DriverConfiguration.class);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
List<MLink> linkList = links(link(1,1), link(2,1));
@@ -724,54 +646,23 @@ public class TestJdbcRepository {
/**
* Test the exception handling procedure when the database handler fails to
- * find links for driverConfig
- */
- @Test
- public void testDriverConfigUpgradeHandlerFindLinksError() {
- MDriverConfig newDriverConfig = driverConfig();
-
- when(driverMock.getValidator()).thenReturn(validatorMock);
- when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
-
- SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
- "find links error.");
- doThrow(exception).when(repoHandlerMock).findLinks(any(Connection.class));
-
- try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
- } catch (SqoopException ex) {
- assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
- verifyNoMoreInteractions(repoHandlerMock);
- return ;
- }
-
- fail("Should throw out an exception with message: " + exception.getMessage());
- }
-
- /**
- * Test the exception handling procedure when the database handler fails to
* find jobs for driverConfig
*/
@Test
- public void testDriverConfigUpgradeHandlerFindJobsError() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeHandlerWithFindJobsError() {
+ MDriver newDriverConfig = driver();
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- List<MLink> linkList = links(link(1,1), link(2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
-
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"find jobs error.");
doThrow(exception).when(repoHandlerMock).findJobs(any(Connection.class));
try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
@@ -785,15 +676,13 @@ public class TestJdbcRepository {
* delete job inputs for driverConfig upgrade
*/
@Test
- public void testDriverConfigUpgradeHandlerDeleteJobInputsError() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeHandlerWithDeleteJobInputsError() {
+ MDriver newDriverConfig = driver();
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
@@ -801,10 +690,9 @@ public class TestJdbcRepository {
doThrow(exception).when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verify(repoHandlerMock, times(1)).deleteJobInputs(anyLong(), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
@@ -816,71 +704,31 @@ public class TestJdbcRepository {
/**
* Test the exception handling procedure when the database handler fails to
- * delete link inputs for driverConfig upgrade
- */
- @Test
- public void testDriverConfigUpgradeHandlerDeleteConnectionInputsError() {
- MDriverConfig newDriverConfig = driverConfig();
-
- when(driverMock.getValidator()).thenReturn(validatorMock);
- when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
-
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
- doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
-
- SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
- "delete link inputs error.");
- doThrow(exception).when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
-
- try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
- } catch (SqoopException ex) {
- assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
- verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).deleteLinkInputs(anyLong(), any(Connection.class));
- verifyNoMoreInteractions(repoHandlerMock);
- return ;
- }
-
- fail("Should throw out an exception with message: " + exception.getMessage());
- }
-
- /**
- * Test the exception handling procedure when the database handler fails to
* update the driverConfig entity
*/
@Test
- public void testDriverConfigUpgradeHandlerUpdateDriverConfigError() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeHandlerWithUpdateDriverConfigError() {
+ MDriver newDriverConfig = driver();
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update driverConfig entity error.");
- doThrow(exception).when(repoHandlerMock).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
+ doThrow(exception).when(repoHandlerMock).updateDriver(any(MDriver.class), any(Connection.class));
try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
+ verify(repoHandlerMock, times(1)).updateDriver(any(MDriver.class), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -888,93 +736,38 @@ public class TestJdbcRepository {
fail("Should throw out an exception with message: " + exception.getMessage());
}
- /**
- * Test the exception handling procedure when the database handler fails to
- * update the link entity
- */
- @Test
- public void testDriverConfigUpgradeHandlerUpdateConnectionError() {
- MDriverConfig newDriverConfig = driverConfig();
-
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
- when(driverMock.getValidator()).thenReturn(validatorMock);
- when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- when(driverMock.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(driverMock.getJobConfigurationClass()).thenReturn(JobConfiguration.class);
-
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
- doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
- doReturn(true).when(repoHandlerMock).existsLink(anyLong(), any(Connection.class));
-
- SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
- "update link error.");
- doThrow(exception).when(repoHandlerMock).updateLink(any(MLink.class), any(Connection.class));
-
- try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
- } catch (SqoopException ex) {
- assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
- verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
- verify(repoHandlerMock, times(1)).existsLink(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).updateLink(any(MLink.class), any(Connection.class));
- verifyNoMoreInteractions(repoHandlerMock);
- return ;
- }
-
- fail("Should throw out an exception with message: " + exception.getMessage());
- }
/**
* Test the exception handling procedure when the database handler fails to
* update the job entity
*/
@Test
- public void testDriverConfigUpgradeHandlerUpdateJobError() {
- MDriverConfig driverConfig = driverConfig();
+ public void testDriverConfigUpgradeHandlerWithUpdateJobError() {
+ MDriver driverConfig = driver();
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- when(driverMock.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(driverMock.getJobConfigurationClass()).thenReturn(JobConfiguration.class);
+ when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyConfigurationGroup.class);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
- doReturn(true).when(repoHandlerMock).existsLink(anyLong(), any(Connection.class));
+ doNothing().when(repoHandlerMock).updateDriver(any(MDriver.class), any(Connection.class));
doReturn(true).when(repoHandlerMock).existsJob(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).updateLink(any(MLink.class), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update job error.");
doThrow(exception).when(repoHandlerMock).updateJob(any(MJob.class), any(Connection.class));
try {
- repoSpy.upgradeDriverConfig(driverConfig);
+ repoSpy.upgradeDriver(driverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
- verify(repoHandlerMock, times(2)).existsLink(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).updateLink(any(MLink.class), any(Connection.class));
+ verify(repoHandlerMock, times(1)).updateDriver(any(MDriver.class), any(Connection.class));
verify(repoHandlerMock, times(1)).existsJob(anyLong(), any(Connection.class));
verify(repoHandlerMock, times(1)).updateJob(any(MJob.class), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
@@ -986,9 +779,9 @@ public class TestJdbcRepository {
private MConnector connector(long connectorId, String version) {
MConnector connector = new MConnector("A" + connectorId, "A" + connectorId, version + connectorId,
- new MConnectionForms(new LinkedList<MForm>()),
- new MJobForms(FormUtils.toForms(JobConfiguration.class)),
- new MJobForms(FormUtils.toForms(JobConfiguration.class)));
+ new MLinkConfig(new LinkedList<MConfig>()),
+ new MFromConfig(ConfigUtils.toConfigs(FromJobConfigurationGroup.class)),
+ new MToConfig(ConfigUtils.toConfigs(ToJobConfigurationGroup.class)));
connector.setPersistenceId(connectorId);
return connector;
}
@@ -997,34 +790,30 @@ public class TestJdbcRepository {
return connector(connectoId, "1.0");
}
- private MDriverConfig driverConfig() {
- MDriverConfig driverConfig = new MDriverConfig(
- new MConnectionForms(new LinkedList<MForm>()),
- new MJobForms(FormUtils.toForms(JobConfiguration.class)),
- Driver.CURRENT_DRIVER_VERSION);
- driverConfig.setPersistenceId(1);
- return driverConfig;
+ private MDriver driver() {
+ MDriver driver = new MDriver(new MDriverConfig(new LinkedList<MConfig>()),
+ DriverBean.CURRENT_DRIVER_VERSION);
+ driver.setPersistenceId(1);
+ return driver;
}
- private MDriverConfig anotherDriverConfig() {
- MDriverConfig driverConfig = new MDriverConfig(null, null,
- Driver.CURRENT_DRIVER_VERSION);
- driverConfig.setPersistenceId(1);
- return driverConfig;
+ private MDriver anotherDriver() {
+ MDriver driver = new MDriver(null, DriverBean.CURRENT_DRIVER_VERSION);
+ driver.setPersistenceId(1);
+ return driver;
}
private MLink link(long linkId, long connectorId) {
- MLink link = new MLink(connectorId, new MConnectionForms(new LinkedList<MForm>()),
- new MConnectionForms(new LinkedList<MForm>()));
+ MLink link = new MLink(connectorId, new MLinkConfig(new LinkedList<MConfig>()));
link.setPersistenceId(linkId);
return link;
}
private MJob job(long id, long fromConnectorId, long toConnectorId, long fromLinkId, long toLinkId) {
MJob job = new MJob(fromConnectorId, toConnectorId, fromLinkId, toLinkId,
- new MJobForms(new LinkedList<MForm>()),
- new MJobForms(new LinkedList<MForm>()),
- new MJobForms(new LinkedList<MForm>()));
+ new MFromConfig(new LinkedList<MConfig>()),
+ new MToConfig(new LinkedList<MConfig>()),
+ new MDriverConfig(new LinkedList<MConfig>()));
job.setPersistenceId(id);
return job;
}
@@ -1042,6 +831,12 @@ public class TestJdbcRepository {
}
@ConfigurationClass
- public static class EmptyConfigurationClass {
+ public static class EmptyConfigurationGroup {
+ }
+ @ConfigurationClass
+ public static class FromJobConfigurationGroup {
+ }
+ @ConfigurationClass
+ public static class ToJobConfigurationGroup {
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java b/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java
index 83c670c..5423b7b 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java
@@ -526,4 +526,4 @@ public class Data implements WritableComparable<Data> {
String replacement = String.valueOf(stringDelimiter);
return string.replaceAll(regex, replacement);
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
index b533837..0fa07f7 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
@@ -25,7 +25,7 @@ import org.apache.log4j.PropertyConfigurator;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.job.JobConstants;
import org.apache.sqoop.json.util.SchemaSerialization;
-import org.apache.sqoop.model.FormUtils;
+import org.apache.sqoop.model.ConfigUtils;
import org.apache.sqoop.schema.Schema;
import org.apache.sqoop.utils.ClassUtils;
import org.json.simple.JSONObject;
@@ -40,47 +40,35 @@ import java.util.Properties;
*/
public final class ConfigurationUtils {
- private static final String JOB_CONFIG_CLASS_FROM_CONNECTOR_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.from.connection";
+ private static final String MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_LINK = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.from.link";
- private static final String JOB_CONFIG_CLASS_TO_CONNECTOR_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.to.connection";
+ private static final String MR_JOB_CONFIG_CLASS_TO_CONNECTOR_LINK = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.to.link";
- private static final String JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.from.job";
+ private static final String MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.from.job";
- private static final String JOB_CONFIG_CLASS_TO_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.to.job";
+ private static final String MR_JOB_CONFIG_CLASS_TO_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.to.job";
- private static final String JOB_CONFIG_CLASS_FROM_FRAMEWORK_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.class.framework.from.connection";
+ private static final String MR_JOB_CONFIG_DRIVER_CONFIG_CLASS = JobConstants.PREFIX_JOB_CONFIG + "config.class.driver";
- private static final String JOB_CONFIG_CLASS_TO_FRAMEWORK_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.class.framework.to.connection";
+ private static final String MR_JOB_CONFIG_FROM_CONNECTOR_LINK = JobConstants.PREFIX_JOB_CONFIG + "config.connector.from.link";
- private static final String JOB_CONFIG_CLASS_FRAMEWORK_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.framework.job";
+ private static final Text MR_JOB_CONFIG_FROM_CONNECTOR_LINK_KEY = new Text(MR_JOB_CONFIG_FROM_CONNECTOR_LINK);
- private static final String JOB_CONFIG_FROM_CONNECTOR_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.connector.from.connection";
+ private static final String MR_JOB_CONFIG_TO_CONNECTOR_LINK = JobConstants.PREFIX_JOB_CONFIG + "config.connector.to.link";
- private static final Text JOB_CONFIG_FROM_CONNECTOR_CONNECTION_KEY = new Text(JOB_CONFIG_FROM_CONNECTOR_CONNECTION);
+ private static final Text MR_JOB_CONFIG_TO_CONNECTOR_LINK_KEY = new Text(MR_JOB_CONFIG_TO_CONNECTOR_LINK);
- private static final String JOB_CONFIG_TO_CONNECTOR_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.connector.to.connection";
+ private static final String MR_JOB_CONFIG_FROM_JOB_CONFIG = JobConstants.PREFIX_JOB_CONFIG + "config.connector.from.job";
- private static final Text JOB_CONFIG_TO_CONNECTOR_CONNECTION_KEY = new Text(JOB_CONFIG_TO_CONNECTOR_CONNECTION);
+ private static final Text MR_JOB_CONFIG_FROM_JOB_CONFIG_KEY = new Text(MR_JOB_CONFIG_FROM_JOB_CONFIG);
- private static final String JOB_CONFIG_FROM_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.connector.from.job";
+ private static final String MR_JOB_CONFIG_TO_JOB_CONFIG = JobConstants.PREFIX_JOB_CONFIG + "config.connector.to.job";
- private static final Text JOB_CONFIG_FROM_CONNECTOR_JOB_KEY = new Text(JOB_CONFIG_FROM_CONNECTOR_JOB);
+ private static final Text MR_JOB_CONFIG_TO_JOB_CONFIG_KEY = new Text(MR_JOB_CONFIG_TO_JOB_CONFIG);
- private static final String JOB_CONFIG_TO_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.connector.to.job";
+ private static final String MR_JOB_CONFIG_DRIVER_CONFIG = JobConstants.PREFIX_JOB_CONFIG + "config.driver";
- private static final Text JOB_CONFIG_TO_CONNECTOR_JOB_KEY = new Text(JOB_CONFIG_TO_CONNECTOR_JOB);
-
- private static final String JOB_CONFIG_FROM_FRAMEWORK_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.framework.from.connection";
-
- private static final Text JOB_CONFIG_FROM_FRAMEWORK_CONNECTION_KEY = new Text(JOB_CONFIG_FROM_FRAMEWORK_CONNECTION);
-
- private static final String JOB_CONFIG_TO_FRAMEWORK_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.framework.from.connection";
-
- private static final Text JOB_CONFIG_TO_FRAMEWORK_CONNECTION_KEY = new Text(JOB_CONFIG_TO_FRAMEWORK_CONNECTION);
-
- private static final String JOB_CONFIG_FRAMEWORK_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.framework.job";
-
- private static final Text JOB_CONFIG_FRAMEWORK_JOB_KEY = new Text(JOB_CONFIG_FRAMEWORK_JOB);
+ private static final Text MR_JOB_CONFIG_DRIVER_CONFIG_KEY = new Text(MR_JOB_CONFIG_DRIVER_CONFIG);
private static final String SCHEMA_FROM = JobConstants.PREFIX_JOB_CONFIG + "schema.connector.from";
@@ -92,21 +80,21 @@ public final class ConfigurationUtils {
/**
- * Persist Connector configuration object for connection.
+ * Persist Connector configuration object for link.
*
* @param job MapReduce job object
* @param obj Configuration object
*/
- public static void setConnectorConnectionConfig(Direction type, Job job, Object obj) {
+ public static void setConnectorLinkConfig(Direction type, Job job, Object obj) {
switch (type) {
case FROM:
- job.getConfiguration().set(JOB_CONFIG_CLASS_FROM_CONNECTOR_CONNECTION, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_FROM_CONNECTOR_CONNECTION_KEY, FormUtils.toJson(obj).getBytes());
+ job.getConfiguration().set(MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_LINK, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_FROM_CONNECTOR_LINK_KEY, ConfigUtils.toJson(obj).getBytes());
break;
case TO:
- job.getConfiguration().set(JOB_CONFIG_CLASS_TO_CONNECTOR_CONNECTION, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_TO_CONNECTOR_CONNECTION_KEY, FormUtils.toJson(obj).getBytes());
+ job.getConfiguration().set(MR_JOB_CONFIG_CLASS_TO_CONNECTOR_LINK, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_TO_CONNECTOR_LINK_KEY, ConfigUtils.toJson(obj).getBytes());
break;
}
}
@@ -120,46 +108,27 @@ public final class ConfigurationUtils {
public static void setConnectorJobConfig(Direction type, Job job, Object obj) {
switch (type) {
case FROM:
- job.getConfiguration().set(JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_FROM_CONNECTOR_JOB_KEY, FormUtils.toJson(obj).getBytes());
+ job.getConfiguration().set(MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_FROM_JOB_CONFIG_KEY, ConfigUtils.toJson(obj).getBytes());
break;
case TO:
- job.getConfiguration().set(JOB_CONFIG_CLASS_TO_CONNECTOR_JOB, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_TO_CONNECTOR_JOB_KEY, FormUtils.toJson(obj).getBytes());
+ job.getConfiguration().set(MR_JOB_CONFIG_CLASS_TO_CONNECTOR_JOB, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_TO_JOB_CONFIG_KEY, ConfigUtils.toJson(obj).getBytes());
break;
}
}
- /**
- * Persist Framework configuration object for connection.
- *
- * @param job MapReduce job object
- * @param obj Configuration object
- */
- public static void setFrameworkConnectionConfig(Direction type, Job job, Object obj) {
- switch (type) {
- case FROM:
- job.getConfiguration().set(JOB_CONFIG_CLASS_FROM_FRAMEWORK_CONNECTION, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_FROM_FRAMEWORK_CONNECTION_KEY, FormUtils.toJson(obj).getBytes());
- break;
-
- case TO:
- job.getConfiguration().set(JOB_CONFIG_CLASS_TO_FRAMEWORK_CONNECTION, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_TO_FRAMEWORK_CONNECTION_KEY, FormUtils.toJson(obj).getBytes());
- break;
- }
- }
/**
- * Persist Framework configuration object for job.
+ * Persist driver configuration object for job.
*
* @param job MapReduce job object
* @param obj Configuration object
*/
- public static void setFrameworkJobConfig(Job job, Object obj) {
- job.getConfiguration().set(JOB_CONFIG_CLASS_FRAMEWORK_JOB, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_FRAMEWORK_JOB_KEY, FormUtils.toJson(obj).getBytes());
+ public static void setDriverConfig(Job job, Object obj) {
+ job.getConfiguration().set(MR_JOB_CONFIG_DRIVER_CONFIG_CLASS, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_DRIVER_CONFIG_KEY, ConfigUtils.toJson(obj).getBytes());
}
/**
@@ -185,17 +154,16 @@ public final class ConfigurationUtils {
/**
* Retrieve Connector configuration object for connection.
- *
* @param configuration MapReduce configuration object
* @return Configuration object
*/
public static Object getConnectorConnectionConfig(Direction type, Configuration configuration) {
switch (type) {
case FROM:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_FROM_CONNECTOR_CONNECTION, JOB_CONFIG_FROM_CONNECTOR_CONNECTION_KEY);
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_LINK, MR_JOB_CONFIG_FROM_CONNECTOR_LINK_KEY);
case TO:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_TO_CONNECTOR_CONNECTION, JOB_CONFIG_TO_CONNECTOR_CONNECTION_KEY);
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_CLASS_TO_CONNECTOR_LINK, MR_JOB_CONFIG_TO_CONNECTOR_LINK_KEY);
}
return null;
@@ -210,28 +178,10 @@ public final class ConfigurationUtils {
public static Object getConnectorJobConfig(Direction type, Configuration configuration) {
switch (type) {
case FROM:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB, JOB_CONFIG_FROM_CONNECTOR_JOB_KEY);
-
- case TO:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_TO_CONNECTOR_JOB, JOB_CONFIG_TO_CONNECTOR_JOB_KEY);
- }
-
- return null;
- }
-
- /**
- * Retrieve Framework configuration object for connection.
- *
- * @param configuration MapReduce configuration object
- * @return Configuration object
- */
- public static Object getFrameworkConnectionConfig(Direction type, Configuration configuration) {
- switch (type) {
- case FROM:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_FROM_FRAMEWORK_CONNECTION, JOB_CONFIG_FROM_FRAMEWORK_CONNECTION_KEY);
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB, MR_JOB_CONFIG_FROM_JOB_CONFIG_KEY);
case TO:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_TO_FRAMEWORK_CONNECTION, JOB_CONFIG_TO_FRAMEWORK_CONNECTION_KEY);
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_CLASS_TO_CONNECTOR_JOB, MR_JOB_CONFIG_TO_JOB_CONFIG_KEY);
}
return null;
@@ -243,8 +193,8 @@ public final class ConfigurationUtils {
* @param configuration MapReduce configuration object
* @return Configuration object
*/
- public static Object getFrameworkJobConfig(Configuration configuration) {
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_FRAMEWORK_JOB, JOB_CONFIG_FRAMEWORK_JOB_KEY);
+ public static Object getDriverConfig(Configuration configuration) {
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_DRIVER_CONFIG_CLASS, MR_JOB_CONFIG_DRIVER_CONFIG_KEY);
}
@@ -303,7 +253,7 @@ public final class ConfigurationUtils {
String json = new String(configuration.getCredentials().getSecretKey(valueProperty));
// Fill it with JSON data
- FormUtils.fillValues(json, object);
+ ConfigUtils.fillValues(json, object);
// And give it back
return object;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java
index aecde40..8d2a1da 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java
@@ -37,7 +37,7 @@ public class SqoopDestroyerExecutor {
/**
* Execute destroyer.
*
- * @param success True if the job execution was successfull
+ * @param success True if the job execution was successful
* @param configuration Configuration object to get destroyer class with context
* and configuration objects.
* @param direction The direction of the Destroyer to execute.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java
index 1952cbb..0d14fc7 100644
--- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java
+++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java
@@ -19,8 +19,6 @@ package org.apache.sqoop.job;
import java.io.IOException;
-import org.junit.Assert;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.InputFormat;
@@ -33,6 +31,7 @@ import org.apache.sqoop.job.mr.SqoopInputFormat;
import org.apache.sqoop.job.mr.SqoopMapper;
import org.apache.sqoop.job.mr.SqoopNullOutputFormat;
import org.apache.sqoop.job.mr.SqoopSplit;
+import org.junit.Assert;
public class JobUtils {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java
----------------------------------------------------------------------
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 032cc11..e3b68e2 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
@@ -253,7 +253,6 @@ public class TestMapReduce {
public static class DummyLoader extends Loader {
private int index = START_PARTITION*NUMBER_OF_ROWS_PER_PARTITION;
private Data expected = new Data();
- private CSVIntermediateDataFormat actual = new CSVIntermediateDataFormat();
@Override
public void load(LoaderContext context, Object oc, Object oj) throws Exception{
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java
index 1447e00..501e32c 100644
--- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java
+++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java
@@ -17,130 +17,118 @@
*/
package org.apache.sqoop.job.mr;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapreduce.Job;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
-import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.Config;
+import org.apache.sqoop.model.ConfigClass;
import org.apache.sqoop.model.Input;
-import org.apache.sqoop.model.MJob;
import org.apache.sqoop.schema.Schema;
import org.apache.sqoop.schema.type.Text;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
/**
- * Current tests are using mockito to propagate credentials from Job object
- * to JobConf object. This implementation was chosen because it's not clear
+ * Current tests are using mockito to propagate credentials from hadoop Job object
+ * to hadoop JobConf object. This implementation was chosen because it's not clear
* how MapReduce is converting one object to another.
*/
public class TestConfigurationUtils {
Job job;
- JobConf jobConf;
+ JobConf jobConfSpy;
@Before
public void setUp() throws Exception {
- setUpJob();
- setUpJobConf();
+ setUpHadoopJob();
+ setUpHadoopJobConf();
}
- public void setUpJob() throws Exception {
+ public void setUpHadoopJob() throws Exception {
job = new Job();
}
- public void setUpJobConf() throws Exception {
- jobConf = spy(new JobConf(job.getConfiguration()));
- when(jobConf.getCredentials()).thenReturn(job.getCredentials());
+ public void setUpHadoopJobConf() throws Exception {
+ jobConfSpy = spy(new JobConf(job.getConfiguration()));
+ when(jobConfSpy.getCredentials()).thenReturn(job.getCredentials());
}
@Test
- public void testConfigConnectorConnection() throws Exception {
- ConfigurationUtils.setConnectorConnectionConfig(Direction.FROM, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getConnectorConnectionConfig(Direction.FROM, jobConf));
-
- ConfigurationUtils.setConnectorConnectionConfig(Direction.TO, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getConnectorConnectionConfig(Direction.TO, jobConf));
+ public void testLinkConfiguration() throws Exception {
+ ConfigurationUtils.setConnectorLinkConfig(Direction.FROM, job, getConfig());
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getConnectorConnectionConfig(Direction.FROM, jobConfSpy));
+
+ ConfigurationUtils.setConnectorLinkConfig(Direction.TO, job, getConfig());
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getConnectorConnectionConfig(Direction.TO, jobConfSpy));
}
@Test
- public void testConfigConnectorJob() throws Exception {
+ public void testJobConfiguration() throws Exception {
ConfigurationUtils.setConnectorJobConfig(Direction.FROM, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getConnectorJobConfig(Direction.FROM, jobConf));
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getConnectorJobConfig(Direction.FROM, jobConfSpy));
ConfigurationUtils.setConnectorJobConfig(Direction.TO, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getConnectorJobConfig(Direction.TO, jobConf));
- }
-
- @Test
- public void testConfigFrameworkConnection() throws Exception {
- ConfigurationUtils.setFrameworkConnectionConfig(Direction.FROM, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getFrameworkConnectionConfig(Direction.FROM, jobConf));
-
- ConfigurationUtils.setFrameworkConnectionConfig(Direction.TO, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getFrameworkConnectionConfig(Direction.TO, jobConf));
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getConnectorJobConfig(Direction.TO, jobConfSpy));
}
@Test
- public void testConfigFrameworkJob() throws Exception {
- ConfigurationUtils.setFrameworkJobConfig(job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getFrameworkJobConfig(jobConf));
+ public void testDriverConfiguration() throws Exception {
+ ConfigurationUtils.setDriverConfig(job, getConfig());
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getDriverConfig(jobConfSpy));
}
@Test
public void testConnectorSchema() throws Exception {
ConfigurationUtils.setConnectorSchema(Direction.FROM, job, getSchema("a"));
- assertEquals(getSchema("a"), ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConf));
+ assertEquals(getSchema("a"), ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConfSpy));
ConfigurationUtils.setConnectorSchema(Direction.TO, job, getSchema("b"));
- assertEquals(getSchema("b"), ConfigurationUtils.getConnectorSchema(Direction.TO, jobConf));
+ assertEquals(getSchema("b"), ConfigurationUtils.getConnectorSchema(Direction.TO, jobConfSpy));
}
@Test
public void testConnectorSchemaNull() throws Exception {
ConfigurationUtils.setConnectorSchema(Direction.FROM, job, null);
- assertNull(ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConf));
+ assertNull(ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConfSpy));
ConfigurationUtils.setConnectorSchema(Direction.TO, job, null);
- assertNull(ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConf));
+ assertNull(ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConfSpy));
}
private Schema getSchema(String name) {
return new Schema(name).addColumn(new Text("c1"));
}
- private Config getConfig() {
- Config c = new Config();
- c.f.A = "This is secret text!";
+ private TestConfiguration getConfig() {
+ TestConfiguration c = new TestConfiguration();
+ c.c.A = "This is secret text!";
return c;
}
- @FormClass
- public static class F {
+ @ConfigClass
+ public static class C {
@Input String A;
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof F)) return false;
+ if (!(o instanceof C)) return false;
- F f = (F) o;
+ C c = (C) o;
- if (A != null ? !A.equals(f.A) : f.A != null) return false;
+ if (A != null ? !A.equals(c.A) : c.A != null) return false;
return true;
}
@@ -152,21 +140,21 @@ public class TestConfigurationUtils {
}
@ConfigurationClass
- public static class Config {
- @Form F f;
+ public static class TestConfiguration {
+ @Config C c;
- public Config() {
- f = new F();
+ public TestConfiguration() {
+ c = new C();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof Config)) return false;
+ if (!(o instanceof TestConfiguration)) return false;
- Config config = (Config) o;
+ TestConfiguration config = (TestConfiguration) o;
- if (f != null ? !f.equals(config.f) : config.f != null)
+ if (c != null ? !c.equals(config.c) : config.c != null)
return false;
return true;
@@ -174,7 +162,7 @@ public class TestConfigurationUtils {
@Override
public int hashCode() {
- return f != null ? f.hashCode() : 0;
+ return c != null ? c.hashCode() : 0;
}
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
index 61dc3b4..cc31d06 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
@@ -1,7 +1,7 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional inconfigation
+ * 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