Exemple #1
0
 @AfterClass
 public static void tearDown() throws InterruptedException, ExecutionException, IOException {
   DirDataImpl dirData = new DirDataImpl();
   DirDataImpl.setNumber(3334);
   List<String> paths = dirData.dividePath(rootPath, 30, THREADS);
   List<Future<String>> list = new ArrayList<>();
   try {
     for (String p : paths) {
       Future<String> submit =
           executor.submit(
               () -> {
                 dirData.delDir(p, 6);
                 return "It done!";
               });
       list.add(submit);
     }
     for (Future<String> future : list) {
       future.get();
     }
   } finally {
     executor.shutdown();
     while (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
       LOG.info("Awaiting completion of threads.");
     }
   }
   FileUtils.deleteDirectory(new File(rootPath));
 }
Exemple #2
0
 @Test
 public void visitFolderImplTest() {
   VisitFolder visitFolder = (VisitFolderImpl) context.getBean("visitFolder");
   List<String> paths = DirDataImpl.dividePath(rootPath, 30, THREADS);
   List<FolderData> data = visitFolder.visit(paths.get(4));
   assertEquals(99996, data.size());
 }
Exemple #3
0
 @Test
 public void insertTest() {
   VisitFolder visitFolder = (VisitFolderImpl) context.getBean("visitFolder");
   List<String> paths = DirDataImpl.dividePath(rootPath, 30, THREADS);
   List<FolderData> data = visitFolder.visit(paths.get(4));
   System.out.println(paths.get(4));
   fileDAO.insert(data);
   assertEquals(99996, count());
 }
Exemple #4
0
 @BeforeClass
 public static void setUp() throws InterruptedException, ExecutionException {
   DirDataImpl dirData = new DirDataImpl();
   DirDataImpl.setNumber(3334);
   String path = dirData.buildPath(rootPath, 30);
   dirData.createDir(path);
   List<String> paths = dirData.dividePath(rootPath, 30, THREADS);
   List<Future<String>> list = new ArrayList<>();
   for (String p : paths) {
     Future<String> submit =
         executor.submit(
             () -> {
               dirData.createFiles(p, 6);
               return "It done!";
             });
     list.add(submit);
   }
   for (Future<String> future : list) {
     future.get();
   }
 }