CopyListing extends Configured { protected abstract void validatePaths(DistCpOptions options) throws IOException, InvalidInputException; protected  CopyListing(Configuration configuration, Credentials credentials); final void buildListing(Path pathToListFile,
                                 DistCpOptions options); static CopyListing getCopyListing(Configuration configuration,
                                           Credentials credentials,
                                           DistCpOptions options);  }
@Test public void testMultipleSrcToFile() { FileSystem fs = null; try { fs = FileSystem.get(getConf()); List<Path> srcPaths = new ArrayList<Path>(); srcPaths.add(new Path("/tmp/in/1")); srcPaths.add(new Path("/tmp/in/2")); Path target = new Path("/tmp/out/1"); TestDistCpUtils.createFile(fs, "/tmp/in/1"); TestDistCpUtils.createFile(fs, "/tmp/in/2"); fs.mkdirs(target); DistCpOptions options = new DistCpOptions(srcPaths, target); validatePaths(options); TestDistCpUtils.delete(fs, "/tmp"); target = new Path("/tmp/out/1"); fs.create(target).close(); options = new DistCpOptions(srcPaths, target); try { validatePaths(options); Assert.fail("Invalid inputs accepted"); } catch (InvalidInputException ignore) { } TestDistCpUtils.delete(fs, "/tmp"); srcPaths.clear(); srcPaths.add(new Path("/tmp/in/1")); fs.mkdirs(new Path("/tmp/in/1")); target = new Path("/tmp/out/1"); fs.create(target).close(); options = new DistCpOptions(srcPaths, target); try { validatePaths(options); Assert.fail("Invalid inputs accepted"); } catch (InvalidInputException ignore) { } TestDistCpUtils.delete(fs, "/tmp"); } catch (IOException e) { LOG.error("Exception encountered ", e); Assert.fail("Test input validation failed"); } finally { TestDistCpUtils.delete(fs, "/tmp"); } }
@Test(timeout=10000) public void testMultipleSrcToFile() { FileSystem fs = null; try { fs = FileSystem.get(getConf()); List<Path> srcPaths = new ArrayList<Path>(); srcPaths.add(new Path("/tmp/in/1")); srcPaths.add(new Path("/tmp/in/2")); Path target = new Path("/tmp/out/1"); TestDistCpUtils.createFile(fs, "/tmp/in/1"); TestDistCpUtils.createFile(fs, "/tmp/in/2"); fs.mkdirs(target); DistCpOptions options = new DistCpOptions(srcPaths, target); validatePaths(options); TestDistCpUtils.delete(fs, "/tmp"); target = new Path("/tmp/out/1"); fs.create(target).close(); options = new DistCpOptions(srcPaths, target); try { validatePaths(options); Assert.fail("Invalid inputs accepted"); } catch (InvalidInputException ignore) { } TestDistCpUtils.delete(fs, "/tmp"); srcPaths.clear(); srcPaths.add(new Path("/tmp/in/1")); fs.mkdirs(new Path("/tmp/in/1")); target = new Path("/tmp/out/1"); fs.create(target).close(); options = new DistCpOptions(srcPaths, target); try { validatePaths(options); Assert.fail("Invalid inputs accepted"); } catch (InvalidInputException ignore) { } TestDistCpUtils.delete(fs, "/tmp"); } catch (IOException e) { LOG.error("Exception encountered ", e); Assert.fail("Test input validation failed"); } finally { TestDistCpUtils.delete(fs, "/tmp"); } }