@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)); }
@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()); }
@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()); }
@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(); } }