Package org.apache.sqoop.common

Examples of org.apache.sqoop.common.SqoopException


   * @param input Field name, must be defined in the form class
   * @param message Validation message
   */
  public void addMessage(Status status, String form, String input, String message ) {
    if( klass == null) {
      throw new SqoopException(ValidationError.VALIDATION_0001);
    }

    assert form != null;
    assert message != null;

    // Field for specified form
    Field formField;

    // Load the form field and verify that it exists
    try {
      formField = klass.getDeclaredField(form);
    } catch (NoSuchFieldException e) {
      throw new SqoopException(ValidationError.VALIDATION_0002,
        "Can't get form " + form + " from " + klass.getName(), e);
    }

    // If this is form message, just save the message and continue
    if(input == null) {
      setMessage(status, form, input, message);
      return;
    }

    // Verify that specified input exists on the form
    try {
      formField.getType().getDeclaredField(input);
    } catch (NoSuchFieldException e) {
      throw new SqoopException(ValidationError.VALIDATION_0002,
        "Can't get input " + input + " from form" + formField.getType().getName(), e);
    }

    setMessage(status, form, input, message);
  }
View Full Code Here


        switch (type) {
        case MAP:
          try {
            mInput.setValue((Map<String, String>)input.get(FORM_INPUT_VALUE));
          } catch (ClassCastException e) {
            throw new SqoopException(SerializationError.SERIALIZATION_001, name + " requires a 'map' value.");
          }
          break;
        default:
          mInput.restoreFromUrlSafeValueString(
              (String) input.get(FORM_INPUT_VALUE));
View Full Code Here

    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,
        "upgradeConnector() has been called.");
    doThrow(exception).when(connectorMgr).getConnector(anyString());

    try {
      repo.registerConnector(newConnector, true);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repoHandler, times(1)).findConnector(anyString(), any(Connection.class));
      verify(connectorMgr, times(1)).getConnector(anyString());
      verifyNoMoreInteractions(repoHandler);
      return ;
    }

    fail("Should throw out an exception with message: " + exception.getMessage());
  }
View Full Code Here

    public FormInput(String formInput) {
      assert formInput != null;
      String []parts = formInput.split("\\.");

      if(formInput.isEmpty() || (parts.length != 1 && parts.length != 2)) {
        throw new SqoopException(ValidationError.VALIDATION_0003,
          "Specification " + formInput + " is not in valid format form.input");
      }

      this.form = parts[0];
      if(parts.length == 2) {
View Full Code Here

    MFramework oldFramework = anotherFramework();

    when(repoHandler.findFramework(any(Connection.class))).thenReturn(oldFramework);

    // make the upgradeFramework to throw an exception to prove that it has been called
    SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
        "upgradeFramework() has been called.");
    doThrow(exception).when(repoHandler).findConnections(any(Connection.class));

    try {
      repo.registerFramework(newFramework, true);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repoHandler, times(1)).findFramework(any(Connection.class));
      verify(repoHandler, times(1)).findConnections(any(Connection.class));
      verifyNoMoreInteractions(repoHandler);
      return ;
    }

    fail("Should throw out an exception with message: " + exception.getMessage());
  }
View Full Code Here

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

    SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
        "find connections for connector error.");
    doThrow(exception).when(repoHandler).findConnectionsForConnector(anyLong(), any(Connection.class));

    try {
      repo.upgradeConnector(oldConnector, newConnector);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repoHandler, times(1)).findConnectionsForConnector(anyLong(), any(Connection.class));
      verifyNoMoreInteractions(repoHandler);
      return ;
    }

    fail("Should throw out an exception with message: " + exception.getMessage());
  }
View Full Code Here

    when(connectorMgr.getConnector(anyString())).thenReturn(sqconnector);

    List<MConnection> connectionList = connections(connection(1,1), connection(2,1));
    doReturn(connectionList).when(repoHandler).findConnectionsForConnector(anyLong(), any(Connection.class));

    SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
        "find jobs for connector error.");
    doThrow(exception).when(repoHandler).findJobsForConnector(anyLong(), any(Connection.class));

    try {
      repo.upgradeConnector(oldConnector, newConnector);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repoHandler, times(1)).findConnectionsForConnector(anyLong(), any(Connection.class));
      verify(repoHandler, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
      verifyNoMoreInteractions(repoHandler);
      return ;
    }

    fail("Should throw out an exception with message: " + exception.getMessage());
  }
View Full Code Here

    List<MConnection> connectionList = connections(connection(1,1), connection(2,1));
    List<MJob> jobList = jobs(job(1,1,1), job(2,1,2));
    doReturn(connectionList).when(repoHandler).findConnectionsForConnector(anyLong(), any(Connection.class));
    doReturn(jobList).when(repoHandler).findJobsForConnector(anyLong(), any(Connection.class));

    SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
        "delete job inputs for connector error.");
    doThrow(exception).when(repoHandler).deleteJobInputs(anyLong(), any(Connection.class));

    try {
      repo.upgradeConnector(oldConnector, newConnector);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repoHandler, times(1)).findConnectionsForConnector(anyLong(), any(Connection.class));
      verify(repoHandler, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
      verify(repoHandler, times(1)).deleteJobInputs(anyLong(), any(Connection.class));
      verifyNoMoreInteractions(repoHandler);
      return ;
    }

    fail("Should throw out an exception with message: " + exception.getMessage());
  }
View Full Code Here

    List<MJob> jobList = jobs(job(1,1,1), job(2,1,2));
    doReturn(connectionList).when(repoHandler).findConnectionsForConnector(anyLong(), any(Connection.class));
    doReturn(jobList).when(repoHandler).findJobsForConnector(anyLong(), any(Connection.class));
    doNothing().when(repoHandler).deleteJobInputs(anyLong(), any(Connection.class));

    SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
        "delete connection inputs for connector error.");
    doThrow(exception).when(repoHandler).deleteConnectionInputs(anyLong(), any(Connection.class));

    try {
      repo.upgradeConnector(oldConnector, newConnector);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repoHandler, times(1)).findConnectionsForConnector(anyLong(), any(Connection.class));
      verify(repoHandler, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
      verify(repoHandler, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
      verify(repoHandler, times(1)).deleteConnectionInputs(anyLong(), any(Connection.class));
      verifyNoMoreInteractions(repoHandler);
      return ;
    }

    fail("Should throw out an exception with message: " + exception.getMessage());
  }
View Full Code Here

    doReturn(connectionList).when(repoHandler).findConnectionsForConnector(anyLong(), any(Connection.class));
    doReturn(jobList).when(repoHandler).findJobsForConnector(anyLong(), any(Connection.class));
    doNothing().when(repoHandler).deleteJobInputs(anyLong(), any(Connection.class));
    doNothing().when(repoHandler).deleteConnectionInputs(anyLong(), any(Connection.class));

    SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
        "update connector error.");
    doThrow(exception).when(repoHandler).updateConnector(any(MConnector.class), any(Connection.class));

    try {
      repo.upgradeConnector(oldConnector, newConnector);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repoHandler, times(1)).findConnectionsForConnector(anyLong(), any(Connection.class));
      verify(repoHandler, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
      verify(repoHandler, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
      verify(repoHandler, times(2)).deleteConnectionInputs(anyLong(), any(Connection.class));
      verify(repoHandler, times(1)).updateConnector(any(MConnector.class), any(Connection.class));
      verifyNoMoreInteractions(repoHandler);
      return ;
    }

    fail("Should throw out an exception with message: " + exception.getMessage());
  }
View Full Code Here

TOP

Related Classes of org.apache.sqoop.common.SqoopException

Copyright © 2018 www.massapicom. 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.