コード例 #1
0
  @Test
  public void testConfigureShimNotMapR() throws Exception {
    String[] vars = new String[] {"var1", "var2", "var3", "var4"};
    String[] vals = new String[] {"hdfsHost", "hdfsPort", "jobTrackerHost", "jobTrackerPort"};

    int i = 0;
    when(namedCluster.getHdfsHost()).thenReturn(vars[i++]);
    when(namedCluster.getHdfsPort()).thenReturn(vars[i++]);
    when(namedCluster.getJobTrackerHost()).thenReturn(vars[i++]);
    when(namedCluster.getJobTrackerPort()).thenReturn(vars[i++]);

    for (i = 0; i < vars.length; i++) {
      when(namedCluster.environmentSubstitute(vars[i])).thenReturn(vals[i]);
    }

    i = 0;
    final String testVal = "testVal";
    doAnswer(
            new Answer<Void>() {
              @Override
              public Void answer(InvocationOnMock invocation) throws Throwable {
                ((List<String>) invocation.getArguments()[5]).add(testVal);
                return null;
              }
            })
        .when(hadoopShim)
        .configureConnectionInformation(
            eq(vals[i++]),
            eq(vals[i++]),
            eq(vals[i++]),
            eq(vals[i++]),
            eq(configuration),
            eq(new ArrayList<String>()));

    sqoopService.configureShim(configuration);
    i = 0;
    verify(hadoopShim)
        .configureConnectionInformation(
            eq(vals[i++]),
            eq(vals[i++]),
            eq(vals[i++]),
            eq(vals[i++]),
            eq(configuration),
            eq(new ArrayList<>(Arrays.asList(testVal))));
  }
コード例 #2
0
  @Test
  public void testRunToolSuccess() throws Exception {
    Properties properties = new Properties();
    String testKey = "testKey";
    String testValue = "testValue";
    properties.setProperty(testKey, testValue);
    when(namedCluster.isMapr()).thenReturn(true);

    String[] testArgs = {"testARgs"};
    assertEquals(0, sqoopService.runTool(new ArrayList<>(Arrays.asList(testArgs)), properties));

    verify(configuration).set(testKey, testValue);
    verify(hadoopShim)
        .configureConnectionInformation(
            eq(""), eq(""), eq(""), eq(""), eq(configuration), any(List.class));
    verify(sqoopShim).runTool(eq(testArgs), eq(configuration));
    assertEquals(Boolean.toString(true), System.getProperty(SqoopServiceImpl.SQOOP_THROW_ON_ERROR));
  }
コード例 #3
0
 @Test
 public void testRunToolFailure() {
   when(namedCluster.isMapr()).thenThrow(new RuntimeException());
   assertEquals(1, sqoopService.runTool(new ArrayList<String>(), new Properties()));
 }