Examples of MConnector


Examples of org.apache.sqoop.model.MConnector

  /**
   * Ensure that metadata with all various data types can be successfully
   * serialized into repository and retrieved back.
   */
  public void testMetadataSerialization() throws Exception {
    MConnector connector = getConnector();

    // Serialize the connector with all data types into repository
    handler.registerConnector(connector, getDerbyConnection());

    // Successful serialization should update the ID
    assertNotSame(connector.getPersistenceId(), MPersistableEntity.PERSISTANCE_ID_DEFAULT);

    // Retrieve registered connector
    MConnector retrieved = handler.findConnector(connector.getUniqueName(), getDerbyConnection());
    assertNotNull(retrieved);

    // Original and retrieved connectors should be the same
    assertEquals(connector, retrieved);
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnector

  /**
   * Test that serializing actual data is not an issue.
   */
  public void testDataSerialization() throws Exception {
    MConnector connector = getConnector();
    MFramework framework = getFramework();

    // Register metadata for everything and our new connector
    handler.registerConnector(connector, getDerbyConnection());
    handler.registerFramework(framework, getDerbyConnection());

    // Inserted values
    Map<String, String> map = new HashMap<String, String>();
    map.put("A", "B");

    // Connection object with all various values
    MConnection connection = new MConnection(connector.getPersistenceId(), connector.getConnectionForms(), framework.getConnectionForms());
    MConnectionForms forms = connection.getConnectorPart();
    forms.getStringInput("f.String").setValue("A");
    forms.getMapInput("f.Map").setValue(map);
    forms.getIntegerInput("f.Integer").setValue(1);
    forms.getBooleanInput("f.Boolean").setValue(true);
View Full Code Here

Examples of org.apache.sqoop.model.MConnector

    );

  }

  protected MConnector getConnector() {
    return new MConnector("A", "org.apache.sqoop.test.A", "1.0-test",
      getConnectionForms(), getJobForms());
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnector

    return (MConnector) doWithConnection(new DoWithConnection() {
      @Override
      public Object doIt(Connection conn) throws Exception {
        String connectorUniqueName = mConnector.getUniqueName();

        MConnector result = handler.findConnector(connectorUniqueName, conn);
        if (result == null) {
          handler.registerConnector(mConnector, conn);
          return mConnector;
        } else {
          // Same connector, check if the version is the same.
          // For now, use the "string" versions itself - later we should
          // probably include a build number or something that is
          // monotonically increasing.
          if (result.getUniqueName().equals(mConnector.getUniqueName()) &&
            mConnector.getVersion().compareTo(result.getVersion()) > 0) {
            if (autoUpgrade) {
              upgradeConnector(result, mConnector);
              return mConnector;
            } else {
              throw new SqoopException(RepositoryError.JDBCREPO_0026,
                "Connector: " + mConnector.getUniqueName());
            }
          }
          if (!result.equals(mConnector)) {
            throw new SqoopException(RepositoryError.JDBCREPO_0013,
              "Connector: " + mConnector.getUniqueName()
                + " given: " + mConnector
                + " found: " + result);
          }
View Full Code Here

Examples of org.apache.sqoop.model.MConnector

  /**
   * Test the procedure when the connector auto upgrade option is enabled
   */
  @Test
  public void testConnectorEnableAutoUpgrade() {
    MConnector newConnector = connector(1, "1.1");
    MConnector oldConnector = connector(1, "1.0");

    when(repoHandler.findConnector(anyString(), any(Connection.class))).thenReturn(oldConnector);

    // make the upgradeConnector to throw an exception to prove that it has been called
    SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
View Full Code Here

Examples of org.apache.sqoop.model.MConnector

  /**
   * Test the procedure when  the connector auto upgrade option is disabled
   */
  @Test
  public void testConnectorDisableAutoUpgrade() {
    MConnector newConnector = connector(1, "1.1");
    MConnector oldConnector = connector(1);

    when(repoHandler.findConnector(anyString(), any(Connection.class))).thenReturn(oldConnector);

    try {
      repo.registerConnector(newConnector, false);
View Full Code Here

Examples of org.apache.sqoop.model.MConnector

   * Test the connector upgrade procedure, when all the connections and
   * jobs using the old connector are still valid for the new connector
   */
  @Test
  public void testConnectorUpgradeWithValidConnectionsAndJobs() {
    MConnector newConnector = connector(1, "1.1");
    MConnector oldConnector = connector(1);

    // prepare the sqoop connector
    SqoopConnector sqconnector = mock(SqoopConnector.class);
    when(validator.validateConnection(any(MConnection.class))).thenReturn(valid);
    when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(valid);
View Full Code Here

Examples of org.apache.sqoop.model.MConnector

   * Test the connector upgrade procedure, when all the connections and
   * jobs using the old connector are invalid for the new connector
   */
  @Test
  public void testConnectorUpgradeWithInvalidConnectionsAndJobs() {
    MConnector newConnector = connector(1, "1.1");
    MConnector oldConnector = connector(1);

    SqoopConnector sqconnector = mock(SqoopConnector.class);
    when(validator.validateConnection(any(MConnection.class))).thenReturn(invalid);
    when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(invalid);
    when(sqconnector.getValidator()).thenReturn(validator);
View Full Code Here

Examples of org.apache.sqoop.model.MConnector

   * Test the exception handling procedure when the database handler fails to
   * find connections for a given connector
   */
  @Test
  public void testConnectorUpgradeHandlerFindConnectionsForConnectorError() {
    MConnector newConnector = connector(1, "1.1");
    MConnector oldConnector = connector(1);

    SqoopConnector sqconnector = mock(SqoopConnector.class);
    when(sqconnector.getValidator()).thenReturn(validator);
    when(sqconnector.getMetadataUpgrader()).thenReturn(upgrader);
    when(connectorMgr.getConnector(anyString())).thenReturn(sqconnector);
View Full Code Here

Examples of org.apache.sqoop.model.MConnector

   * Test the exception handling procedure when the database handler fails to
   * find jobs for a given connector
   */
  @Test
  public void testConnectorUpgradeHandlerFindJobsForConnectorError() {
    MConnector newConnector = connector(1, "1.1");
    MConnector oldConnector = connector(1);

    SqoopConnector sqconnector = mock(SqoopConnector.class);
    when(sqconnector.getValidator()).thenReturn(validator);
    when(sqconnector.getMetadataUpgrader()).thenReturn(upgrader);
    when(connectorMgr.getConnector(anyString())).thenReturn(sqconnector);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.