@Test public void testRecursion() throws IOException, InterruptedException, FolderObserver.FolderNotExistingException { mCurrentTest = "testRecursion"; File subFolder = new File(mTestFolder, "subfolder"); subFolder.mkdir(); FolderObserver fo = new FolderObserver(this, createFolder(mCurrentTest)); File testFile = new File(subFolder, "test"); mLatch = new CountDownLatch(1); testFile.createNewFile(); Assert.assertTrue(mLatch.await(1, TimeUnit.SECONDS)); fo.stopWatching(); }
@Test public void testRemoveFile() throws IOException, InterruptedException, FolderObserver.FolderNotExistingException { mCurrentTest = "testRemoveFile"; File test = new File(mTestFolder, "test"); test.createNewFile(); FolderObserver fo = new FolderObserver(this, createFolder(mCurrentTest)); mLatch = new CountDownLatch(1); test.delete(); Assert.assertTrue(mLatch.await(1, TimeUnit.SECONDS)); Assert.assertEquals(0, mLatch.getCount()); fo.stopWatching(); }
private void shutdown() { if (mEventProcessor != null) mEventProcessor.shutdown(); if (mRunnable != null) mRunnable.killSyncthing(); if (mApi != null) mApi.shutdown(); NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); stopForeground(false); nm.cancel(NOTIFICATION_ACTIVE); for (FolderObserver ro : mObservers) { ro.stopWatching(); } mObservers.clear(); }