mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Fixed a race condition: start the monitor before creating files.
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
<path refid='test-classes'/>
|
<path refid='test-classes'/>
|
||||||
<path refid='util-classes'/>
|
<path refid='util-classes'/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
<jvmarg value='-Djava.library.path=../lib'/>
|
||||||
<test name='net.sf.briar.LockFairnessTest'/>
|
<test name='net.sf.briar.LockFairnessTest'/>
|
||||||
<test name='net.sf.briar.ProtocolIntegrationTest'/>
|
<test name='net.sf.briar.ProtocolIntegrationTest'/>
|
||||||
<test name='net.sf.briar.crypto.CounterModeTest'/>
|
<test name='net.sf.briar.crypto.CounterModeTest'/>
|
||||||
|
|||||||
@@ -36,15 +36,14 @@ public class UnixRemovableDriveMonitorTest extends TestCase {
|
|||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
final List<File> detected = new ArrayList<File>();
|
final List<File> detected = new ArrayList<File>();
|
||||||
// Create a monitor that will wait for two files before stopping
|
// Create a monitor that will wait for two files before stopping
|
||||||
|
final RemovableDriveMonitor monitor = createMonitor(testDir);
|
||||||
|
monitor.start();
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
RemovableDriveMonitor monitor = createMonitor(testDir);
|
|
||||||
monitor.start();
|
|
||||||
detected.add(monitor.waitForInsertion());
|
detected.add(monitor.waitForInsertion());
|
||||||
detected.add(monitor.waitForInsertion());
|
detected.add(monitor.waitForInsertion());
|
||||||
monitor.stop();
|
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
fail();
|
fail();
|
||||||
@@ -57,7 +56,8 @@ public class UnixRemovableDriveMonitorTest extends TestCase {
|
|||||||
assertTrue(file1.createNewFile());
|
assertTrue(file1.createNewFile());
|
||||||
assertTrue(file2.createNewFile());
|
assertTrue(file2.createNewFile());
|
||||||
// Wait for the monitor to detect the files
|
// Wait for the monitor to detect the files
|
||||||
latch.await(1, TimeUnit.SECONDS);
|
assertTrue(latch.await(2, TimeUnit.SECONDS));
|
||||||
|
monitor.stop();
|
||||||
// Check that both files were detected
|
// Check that both files were detected
|
||||||
assertEquals(2, detected.size());
|
assertEquals(2, detected.size());
|
||||||
assertTrue(detected.contains(file1));
|
assertTrue(detected.contains(file1));
|
||||||
|
|||||||
Reference in New Issue
Block a user