コード例 #1
0
 @Test
 public void testUnknownJob() {
   long testJobId = 555l;
   SqoopException exception =
       new SqoopException(DriverError.DRIVER_0004, "Unknown job id: " + testJobId);
   when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
   when(jdbcRepoMock.findJob(testJobId)).thenReturn(null);
   try {
     jobManager.getJob(testJobId);
   } catch (SqoopException ex) {
     assertEquals(ex.getMessage(), exception.getMessage());
     verify(repositoryManagerMock, times(1)).getRepository();
     verify(jdbcRepoMock, times(1)).findJob(testJobId);
   }
 }
コード例 #2
0
  @Test
  public void testDisabledJob() {
    MJob testJob = job(123l, 456l);
    testJob.setEnabled(false);
    testJob.setPersistenceId(1111);
    SqoopException exception =
        new SqoopException(DriverError.DRIVER_0009, "Job id: " + testJob.getPersistenceId());

    MJob mJobSpy = org.mockito.Mockito.spy(testJob);
    when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
    when(jdbcRepoMock.findJob(123l)).thenReturn(mJobSpy);
    try {
      jobManager.getJob(123l);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repositoryManagerMock, times(1)).getRepository();
      verify(jdbcRepoMock, times(1)).findJob(123l);
    }
  }
コード例 #3
0
  @Test
  public void testDisabledLink() {
    MLink testConnection = new MLink(123l, null);
    testConnection.setPersistenceId(1234);
    testConnection.setEnabled(false);
    SqoopException exception =
        new SqoopException(
            DriverError.DRIVER_0010, "Connection id: " + testConnection.getPersistenceId());

    MLink mConnectionSpy = org.mockito.Mockito.spy(testConnection);
    when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
    when(jdbcRepoMock.findLink(123l)).thenReturn(mConnectionSpy);
    try {
      jobManager.getLink(123l);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repositoryManagerMock, times(1)).getRepository();
      verify(jdbcRepoMock, times(1)).findLink(123l);
    }
  }
コード例 #4
0
  @Test
  public void testUnsupportedDirectionForConnector() {
    // invalid job id/ direction
    SqoopException exception =
        new SqoopException(
            DriverError.DRIVER_0011,
            "Connector: " + sqoopConnectorMock.getClass().getCanonicalName());
    List<Direction> supportedDirections = getSupportedDirections();
    when(sqoopConnectorMock.getSupportedDirections()).thenReturn(supportedDirections);

    try {
      // invalid direction
      jobManager.validateSupportedDirection(sqoopConnectorMock, null);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(sqoopConnectorMock, times(1)).getSupportedDirections();
      return;
    }

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